Hi,
I'm on nRF9160 with NCS v2.0.2 and try to enable the Memfault compact logs (https://docs.memfault.com/docs/mcu/compact-logs/).
This requires enabling GNU Compiler extension as described in there FAQ (docs.memfault.com/.../
This means instead of compiling with -std=c99 (this looks to be the standard for NCS v2.0.2) I need to compile with -std=gnu99 ( or as alternative -std=gnu11).
I inserted the following line in my top level CMakeLists.txt:
set_property(GLOBAL PROPERTY CSTD gnu99)
This indeed directs the compiler to use -std=gnu99.
Unfortunately my build fails with conflicting and duplicate symbols in NCS and toolchain network header files:
In file included from /opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket.h:29,
from /opt/nordic/ncs/v2.0.2/modules/lib/device-common/zephyr/../include/devicecommon/socket_utils.h:4,
from ../src/cloud/coap_cloud.c:6:
/opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket_select.h:111: warning: "fd_set" redefined
111 | #define fd_set zsock_fd_set
|
In file included from /opt/nordic/ncs/toolchains/v2.0.2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:50,
from /opt/nordic/ncs/v2.0.2/zephyr/subsys/net/lib/lwm2m/./lwm2m_object.h:55,
from ../src/cloud/coap_cloud.h:6,
from ../src/cloud/coap_cloud.c:4:
/opt/nordic/ncs/toolchains/v2.0.2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/select.h:46: note: this is the location of the previous definition
46 | #define fd_set _types_fd_set
|
In file included from /opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket.h:29,
from /opt/nordic/ncs/v2.0.2/modules/lib/device-common/zephyr/../include/devicecommon/socket_utils.h:4,
from ../src/cloud/coap_cloud.c:6:
/opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket_select.h:112: warning: "FD_SETSIZE" redefined
112 | #define FD_SETSIZE ZSOCK_FD_SETSIZE
|
In file included from /opt/nordic/ncs/toolchains/v2.0.2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:50,
from /opt/nordic/ncs/v2.0.2/zephyr/subsys/net/lib/lwm2m/./lwm2m_object.h:55,
from ../src/cloud/coap_cloud.h:6,
from ../src/cloud/coap_cloud.c:4:
/opt/nordic/ncs/toolchains/v2.0.2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/select.h:31: note: this is the location of the previous definition
31 | # define FD_SETSIZE 64
|
In file included from /opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket.h:29,
from /opt/nordic/ncs/v2.0.2/modules/lib/device-common/zephyr/../include/devicecommon/socket_utils.h:4,
from ../src/cloud/coap_cloud.c:6:
/opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket_select.h:114:19: error: conflicting types for 'select'
114 | static inline int select(int nfds, zsock_fd_set *readfds,
| ^~~~~~
In file included from /opt/nordic/ncs/toolchains/v2.0.2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/types.h:50,
from /opt/nordic/ncs/v2.0.2/zephyr/subsys/net/lib/lwm2m/./lwm2m_object.h:55,
from ../src/cloud/coap_cloud.h:6,
from ../src/cloud/coap_cloud.c:4:
/opt/nordic/ncs/toolchains/v2.0.2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/sys-include/sys/select.h:62:5: note: previous declaration of 'select' was here
62 | int select __P ((int __n, fd_set *__readfds, fd_set *__writefds,
| ^~~~~~
/opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket_select.h:121:20: error: expected identifier or '(' before '__extension__'
121 | static inline void FD_ZERO(zsock_fd_set *set)
| ^~~~~~~
/opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket_select.h:126:49: error: expected ')' before '*' token
126 | static inline int FD_ISSET(int fd, zsock_fd_set *set)
| ^
/opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket_select.h:126:19: error: expected ')' before '->' token
126 | static inline int FD_ISSET(int fd, zsock_fd_set *set)
| ^~~~~~~~
/opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket_select.h:131:48: error: expected ')' before '*' token
131 | static inline void FD_CLR(int fd, zsock_fd_set *set)
| ^
/opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket_select.h:131:20: error: expected ')' before '->' token
131 | static inline void FD_CLR(int fd, zsock_fd_set *set)
| ^~~~~~
/opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket_select.h:136:48: error: expected ')' before '*' token
136 | static inline void FD_SET(int fd, zsock_fd_set *set)
| ^
/opt/nordic/ncs/v2.0.2/zephyr/include/zephyr/net/socket_select.h:136:20: error: expected ')' before '->' token
136 | static inline void FD_SET(int fd, zsock_fd_set *set)
| ^~~~~~
[92/453] Building C object CMakeFiles/app.dir/src/events/sensor_event.c.obj
ninja: build stopped: subcommand failed.
Any idea how to fix this?
Thanks
Andre