Conflict when using net/socket.h and sys/select.h from NCS

To reproduce: Include the net/socket.h and sys/select.h in the same file. There are multiple errors generated due to redefinition of function names:

ncs\v1.8.0\zephyr\include\net\socket_select.h:112:17: error: redefinition of 'struct zsock_timeval'
  112 | #define timeval zsock_timeval

ncs\v1.8.0\toolchain\opt\arm-none-eabi\include\sys\select.h:62:5: error: conflicting declaration of C function 'int select(int, _types_fd_set*, _types_fd_set*, _types_fd_set*, zsock_timeval*)'
   62 | int select __P ((int __n, fd_set *__readfds, fd_set *__writefds,

ncs\v1.8.0\zephyr\include\net\socket_select.h:115:19: note: previous declaration 'int select(int, zsock_fd_set*, zsock_fd_set*, zsock_fd_set*, zsock_timeval*)'
  115 | static inline int select(int nfds, zsock_fd_set *readfds,

  • Hi,

    What are you trying to achieve? What do you need from sys/select.h that you can't get from the zephyr library?

  • I'm trying to use the Edge Impulse library with the modem library in the nRF9160. In the Edge Impulse library they used the sys/select.h which has some symbols which are redefined in the net/socket_select.h library, causing the conflicts.

  • Try adding CONFIG_POSIX_API=y to your prj.conf and see if that helps.

  • Unfortunately, it generates more errors of the following:

    In file included from \ncs\v1.8.0\zephyr\include\posix\time.h:61,
                     from \ncs\v1.8.0\toolchain\opt\arm-none-eabi\include\c++c:\9.2.1\ctime:42,
                     from \ncs\v1.8.0\toolchain\opt\arm-none-eabi\include\c++c:\9.2.1\bits\locale_facets_nonio.h:39,
                     from \ncs\v1.8.0\toolchain\opt\arm-none-eabi\include\c++c:\9.2.1\locale:41,
                     from \ncs\v1.8.0\toolchain\opt\arm-none-eabi\include\c++c:\9.2.1\iomanip:43,
                     from\Documents\Git\thingy91-fall-detection\firmware\adxl362\edge-impulse-sdk\third_party\flatbuffers\include\flatbuffers\util.h:32,
                     from \Documents\Git\thingy91-fall-detection\firmware\adxl362\edge-impulse-sdk\third_party\flatbuffers\include\flatbuffers\flexbuffers.h:24,
                     from \Documents\Git\thingy91-fall-detection\firmware\adxl362\edge-impulse-sdk\tensorflow\lite\micro\kernels\circular_buffer.cc:17:
    ncs\v1.8.0\zephyr\include\posix\posix_types.h:47:15: error: conflicting declaration 'typedef void* pthread_t'
       47 | typedef void *pthread_t;

    If I remove CONFIG_POSIX_API=y and reinstate CONFIG_NET_SOCKETS_POSIX_NAMES=y, then this error goes away.

Related