From bertrand at jacquin.bzh Sun Mar 20 14:51:30 2022 From: bertrand at jacquin.bzh (Bertrand Jacquin) Date: Sun, 20 Mar 2022 13:51:30 +0000 Subject: Gnuk 1.2.19 fails to build with gcc-11.2.1 Message-ID: Hi, Gnuk 1.2.19 fails to build with gcc-11.2.1 due to type conflict: arm-none-eabi-gcc -O2 -g -Wa,-alms=regnual.lst -fpie -Wall -Wextra -Wstrict-prototypes -I . -I ../chopstx -fno-common -mcpu=cortex-m3 -mthumb -DTHUMB -mno-thumb-interwork -DMEMORY_SIZE=20 -DMHZ=72 -DFREE_STANDING -c -o regnual.o regnual.c In file included from regnual.c:31: types.h:1:23: error: conflicting types for ?size_t?; have ?long unsigned int? 1 | typedef unsigned long size_t; | ^~~~~~ In file included from /usr/arm-none-eabi/include/sys/reent.h:14, from /usr/arm-none-eabi/include/string.h:11, from regnual.c:29: /usr/lib/gcc/arm-none-eabi/11.2.1/include/stddef.h:209:23: note: previous declaration of ?size_t? with type ?size_t? {aka ?unsigned int?} 209 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ It it safe to assume that type used by gnuk should be redefined to avoid conflict with compiler provided types ? Cheers, Bertrand -- Bertrand From gniibe at fsij.org Tue Mar 22 07:38:59 2022 From: gniibe at fsij.org (NIIBE Yutaka) Date: Tue, 22 Mar 2022 15:38:59 +0900 Subject: Gnuk 1.2.19 fails to build with gcc-11.2.1 In-Reply-To: References: Message-ID: <87bkxya3uk.fsf@jumper.gniibe.org> Hello, Thank you for your report. Bertrand Jacquin wrote: > In file included from regnual.c:31: > types.h:1:23: error: conflicting types for ?size_t?; have ?long unsigned int? > 1 | typedef unsigned long size_t; > | ^~~~~~ > In file included from /usr/arm-none-eabi/include/sys/reent.h:14, > from /usr/arm-none-eabi/include/string.h:11, > from regnual.c:29: > /usr/lib/gcc/arm-none-eabi/11.2.1/include/stddef.h:209:23: note: previous declaration of ?size_t? with type ?size_t? {aka ?unsigned int?} > 209 | typedef __SIZE_TYPE__ size_t; > | ^~~~~~ > > It it safe to assume that type used by gnuk should be redefined to avoid > conflict with compiler provided types ? ABI wise, it is same; Both are 32-bit unsigned integer. You can just remove the definition of size_t in regnual/types.h. I'll fix. Initially, when Gnuk started, I assumed freestanding environment. That is, an environment with no C library. That's why we have the header file regnual/types.h and declaration of memset in regnural.c. It worked, for a while, in the past. But GCC changed (or clarified its requirement for freestanding environment). GCC requires the freestanding environment to provide memcpy/memmove/memset/memcmp functions. Instead of providing the required functions, I moved to use newlib for that. Note that most parts of Gnuk (for MCU) never depends on C library, still. Now, Gnuk supports emulation, in this case, it uses GNU C library. (regnual only runs on MCU, not emulation.) -- From bertrand at jacquin.bzh Sat Mar 26 21:26:14 2022 From: bertrand at jacquin.bzh (Bertrand Jacquin) Date: Sat, 26 Mar 2022 20:26:14 +0000 Subject: [PATCH] regnual: remove duplicate type declaration In-Reply-To: <87bkxya3uk.fsf@jumper.gniibe.org> References: <87bkxya3uk.fsf@jumper.gniibe.org> Message-ID: <20220326202614.967371-1-bertrand@jacquin.bzh> In file included from regnual.c:31: types.h:1:23: error: conflicting types for ?size_t?; have ?long unsigned int? 1 | typedef unsigned long size_t; | ^~~~~~ In file included from /usr/arm-none-eabi/include/sys/reent.h:14, from /usr/arm-none-eabi/include/string.h:11, from regnual.c:29: /usr/lib/gcc/arm-none-eabi/11.2.1/include/stddef.h:209:23: note: previous declaration of ?size_t? with type ?size_t? {aka ?unsigned int?} 209 | typedef __SIZE_TYPE__ size_t; | --- regnual/regnual.c | 2 -- regnual/types.h | 4 ---- 2 files changed, 6 deletions(-) diff --git a/regnual/regnual.c b/regnual/regnual.c index e296d51bc53e..fbc6064874ac 100644 --- a/regnual/regnual.c +++ b/regnual/regnual.c @@ -32,8 +32,6 @@ #include "usb_lld.h" #include "sys.h" -extern void *memset (void *s, int c, size_t n); - extern void set_led (int); extern int flash_write (uint32_t dst_addr, const uint8_t *src, size_t len); extern int flash_protect (void); diff --git a/regnual/types.h b/regnual/types.h index 6527e0ba206c..0f70f97d0556 100644 --- a/regnual/types.h +++ b/regnual/types.h @@ -1,5 +1,3 @@ -typedef unsigned long size_t; - typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; @@ -7,5 +5,3 @@ typedef unsigned int uintptr_t; #define TRUE 1 #define FALSE 0 - -#define NULL 0