Hi,
I see typedef conflict between #include<sys/types.h> and #include"FreeRTOS_POSIX/sys/types.h"
riscv64-unknown-elf-gcc --version
riscv64-unknown-elf-gcc (GCC) 9.2.0
FreeRTOS Source from
Building this code on Ubuntu 18.04
What i am trying todo :
Building FreeRTOS + POSIXs lib with GCC for RISC V arch.
The issue I see :
Conflicting type definitions between GCC sys/types.h and FreeRTOS_POSIX/sys/types.h,
the stdio.h from GCC includes sys/types.h, so that is leading to the conflict, the freeRTOS code DOES NOT include GCC’s sys/types.h (NO use of #include<sys/types.h>)
Error :
CC posix_demo.c
In file included from …/Source/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX.h:47,
from posix_demo.c:76:
…/Source/lib/include/FreeRTOS_POSIX/sys/types.h:48:38: error: conflicting types for ‘clock_t’
48 | typedef uint32_t clock_t;
| ^~~~~~~
In file included from /opt/riscv64/riscv64-unknown-elf/include/stdio.h:61,
from posix_demo.c:73:
/opt/riscv64/riscv64-unknown-elf/include/sys/types.h:107:19: note: previous declaration of ‘clock_t’ was here
107 | typedef CLOCK_T clock_t;
| ^~~~~~~
In file included from …/Source/lib/FreeRTOS-Plus-POSIX/include/FreeRTOS_POSIX.h:47,
from posix_demo.c:76:
…/Source/lib/include/FreeRTOS_POSIX/sys/types.h:57:38: error: conflicting types for ‘clockid_t’
57 | typedef int clockid_t;
| ^~~~~~~~~
In file included from /opt/riscv64/riscv64-unknown-elf/include/stdio.h:61,
from posix_demo.c:73:
/opt/riscv64/riscv64-unknown-elf/include/sys/types.h:199:21: note: previous declaration of ‘clockid_t’ was here
199 | typedef __clockid_t clockid_t;
| ^~~~~~~~~
I have tried changing the posixconfigENABLE_CLOCK_T / ENABLE_CLOCKID_T in FreeRTOS_POSIX_portable_default.h
82 /**
83 * @name Enable typedefs of POSIX types.
84 *
85 * Set these values to 1 or 0 to enable or disable the typedefs, respectively.
86 * These typedefs should only be disabled if they conflict with system typedefs.
87 */
88 / @{ */
89 #ifndef posixconfigENABLE_CLOCK_T
90 #define posixconfigENABLE_CLOCK_T 1 / < clock_t in sys/types.h */
91 #endif
92 #ifndef posixconfigENABLE_CLOCKID_T
93 #define posixconfigENABLE_CLOCKID_T 1 /**< clockid_t in sys/types.h */
94 #endif
If i have to use the type defs from GCC i.e include<sys/types.h>, then i will have to edit the freeRTOS source files to change - “FreeRTOS_POSIX/sys/types.h” to <sys/types.h> I dont think this will be a good approach
Please suggest how to resolve this issue. Thanks
James