LIBC support: compile error with newlib headers
This happens with arm cortex-m vendor SDK based on FreeRTOS with newlib specs and I don't have a workaround; thanks in advance for any suggestions.
In file included from /home/user/src/camera_app/ext/dialog-sdk/core/system/include/common/da16x_system.h:41,
from /home/user/src/camera_app/src/apps/user_command_server.c:16:
/usr/include/newlib/string.h: At top level:
/usr/include/newlib/string.h:31:9: error: conflicting types for 'memcpy'
31 | void * memcpy (void *__restrict, const void *__restrict, size_t);
| ^~~~~~
In file included from /home/user/src/camera_app/ext/fastmavlink/c_library/uAvionix/../lib/fastmavlink.h:22,
from /home/user/src/camera_app/ext/fastmavlink/c_library/uAvionix/uAvionix.h:40,
from /home/user/src/camera_app/build/sionyx_mavlink_dialect.h:13,
from /home/user/src/camera_app/src/apps/user_command_server.c:11:
/home/user/src/camera_app/ext/fastmavlink/c_library/uAvionix/../lib/fastmavlink_functions.h:453:5: note: previous implicit declaration of 'memcpy' was here
453 | memcpy(msg->payload, &(buf[pos]), msg->len);
| ^~~~~~
In file included from /home/user/src/camera_app/ext/dialog-sdk/core/system/include/common/da16x_system.h:41,
from /home/user/src/camera_app/src/apps/user_command_server.c:16:
/usr/include/newlib/string.h:33:9: error: conflicting types for 'memset'
33 | void * memset (void *, int, size_t);
| ^~~~~~
In file included from /home/user/src/camera_app/ext/fastmavlink/c_library/uAvionix/../lib/fastmavlink.h:22,
from /home/user/src/camera_app/ext/fastmavlink/c_library/uAvionix/uAvionix.h:40,
from /home/user/src/camera_app/build/sionyx_mavlink_dialect.h:13,
from /home/user/src/camera_app/src/apps/user_command_server.c:11:
/home/user/src/camera_app/ext/fastmavlink/c_library/uAvionix/../lib/fastmavlink_functions.h:153:9: note: previous implicit declaration of 'memset' was here
153 | memset(&(msg->payload[msg->len]), 0, msg->payload_max_len - msg->len);
| ^~~~~~
gmake[2]: *** [CMakeFiles/Nightwave.dir/build.make:4012: CMakeFiles/Nightwave.dir/src/apps/user_command_server.c.obj] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: Leaving directory '/home/user/src/camera_app/build'
gmake[1]: *** [CMakeFiles/Makefile2:114: CMakeFiles/Nightwave.dir/all] Error 2
gmake[1]: Leaving directory '/home/user/src/camera_app/build'
gmake: *** [Makefile:94: all] Error 2
ERROR: InvocationError for command /usr/bin/bash -c 'cmake --build build -j $(nproc)' (exited with code 2)
___________________________________ summary ____________________________________
ERROR: build: commands failed
with
$ arm-none-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-none-eabi/10.3.1/lto-wrapper
Target: arm-none-eabi
Configured with: ../configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/lib/include' --mandir='/usr/lib/share/man' --infodir='/usr/lib/share/info' --sysconfdir=/etc --localstatedir=/var --disable-option-checking --disable-silent-rules --libdir='/usr/lib/lib/x86_64-linux-gnu' --libexecdir='/usr/lib/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --mandir=/usr/share/man --enable-languages=c,c++,lto --enable-multilib --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --enable-tls --build=x86_64-linux-gnu --target=arm-none-eabi --with-system-zlib --with-gnu-as --with-gnu-ld --with-pkgversion=15:10.3-2021.07-4 --without-included-gettext --prefix=/usr/lib --infodir=/usr/share/doc/gcc-arm-none-eabi/info --htmldir=/usr/share/doc/gcc-arm-none-eabi/html --pdfdir=/usr/share/doc/gcc-arm-none-eabi/pdf --bindir=/usr/bin --libexecdir=/usr/lib --libdir=/usr/lib --disable-libstdc++-v3 --host=x86_64-linux-gnu --with-headers=no --without-newlib --with-multilib-list=rmprofile,aprofile CFLAGS='-g -O2 -ffile-prefix-map=/build/gcc-arm-none-eabi-qMDwcZ/gcc-arm-none-eabi-10.3-2021.07=. -fstack-protector-strong' CPPFLAGS='-Wdate-time -D_FORTIFY_SOURCE=2' CXXFLAGS='-g -O2 -ffile-prefix-map=/build/gcc-arm-none-eabi-qMDwcZ/gcc-arm-none-eabi-10.3-2021.07=. -fstack-protector-strong' DFLAGS=-frelease FCFLAGS='-g -O2 -ffile-prefix-map=/build/gcc-arm-none-eabi-qMDwcZ/gcc-arm-none-eabi-10.3-2021.07=. -fstack-protector-strong' FFLAGS='-g -O2 -ffile-prefix-map=/build/gcc-arm-none-eabi-qMDwcZ/gcc-arm-none-eabi-10.3-2021.07=. -fstack-protector-strong' GCJFLAGS='-g -O2 -ffile-prefix-map=/build/gcc-arm-none-eabi-qMDwcZ/gcc-arm-none-eabi-10.3-2021.07=. -fstack-protector-strong' LDFLAGS=-Wl,-z,relro OBJCFLAGS='-g -O2 -ffile-prefix-map=/build/gcc-arm-none-eabi-qMDwcZ/gcc-arm-none-eabi-10.3-2021.07=. -fstack-protector-strong' OBJCXXFLAGS='-g -O2 -ffile-prefix-map=/build/gcc-arm-none-eabi-qMDwcZ/gcc-arm-none-eabi-10.3-2021.07=. -fstack-protector-strong' INHIBIT_LIBC_CFLAGS=-DUSE_TM_CLONE_REGISTRY=0 AR_FOR_TARGET=arm-none-eabi-ar AS_FOR_TARGET=arm-none-eabi-as LD_FOR_TARGET=arm-none-eabi-ld NM_FOR_TARGET=arm-none-eabi-nm OBJDUMP_FOR_TARGET=arm-none-eabi-objdump RANLIB_FOR_TARGET=arm-none-eabi-ranlib READELF_FOR_TARGET=arm-none-eabi-readelf STRIP_FOR_TARGET=arm-none-eabi-strip SED=/bin/sed SHELL=/bin/sh BASH=/bin/bash CONFIG_SHELL=/bin/bash
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 10.3.1 20210621 (release) (15:10.3-2021.07-4)
My brain must be full; including newlib string header does fix the build errors, but I have no idea what the "best" integration approach might be on your end.
@sarnold sorry for not having responded earlier, I somehow did not got a warning bell and missed it sadly, I do not have an answer. I am not good with all these different environments and platforms given that memcpy and memset are supposed to be standard, I'm a bit surprised there is an issue with them as regards the first error message in line 31, can you figure out what the conflict we do have here?
closing since stale