zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.97k stars 6.68k forks source link

Compilation error when adding lwm2m client on CHIP/matter sample #48937

Closed RomainPelletant closed 2 years ago

RomainPelletant commented 2 years ago

Describe the bug Compilation conflicts on socket API when compiling lwm2m library and CHIP (matter) library. The first uses SOCKET_POSIX_NAMES and the second seems to use BSD ones. Redefinition of gethostname.

Please also mention any information which could help others to understand the problem you're facing:

To Reproduce Steps to reproduce the behavior:

  1. Open light_bulb sample for nRF for exampe
  2. Add CONFIG_LWM2M=y in prj.conf
  3. compilation

Logs and console output

In file included from C:/Users/Romain/Soft/ncs/zephyr/include/zephyr/posix/pthread.h:13,
                 from C:/Users/Romain/Soft/ncs/zephyr/lib/posix/pthread.c:12:
C:/Users/Romain/Soft/ncs/zephyr/include/zephyr/posix/unistd.h:38:19: error: redefinition of 'gethostname'
   38 | static inline int gethostname(char *buf, size_t len)
      |                   ^~~~~~~~~~~
In file included from C:/Users/Romain/Soft/ncs/zephyr/include/zephyr/posix/unistd.h:13,
                 from C:/Users/Romain/Soft/ncs/zephyr/include/zephyr/posix/pthread.h:13,
                 from C:/Users/Romain/Soft/ncs/zephyr/lib/posix/pthread.c:12:
C:/Users/Romain/Soft/ncs/zephyr/include/zephyr/net/socket.h:809:19: note: previous definition of 'gethostname' was here
  809 | static inline int gethostname(char *buf, size_t len)

Do you have an idea to solve it instead of renaming lwm2m client socket related functions with zsock_ prefix to remove SOCKET_POSIX_NAMES configuration?

carlescufi commented 2 years ago

This is an nRF Connect SDK question. Please ask this in the Nordic Devzone instead: https://devzone.nordicsemi.com/