-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Copy link
Labels
area: C++area: SocketsNetworking socketsNetworking socketsarea: native portHost native arch port (native_sim)Host native arch port (native_sim)bugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug
Description
Describe the bug
There's a compiler error when attempting to build a C++ application for native_posix_64 with combination of Zephyr sockets and some C++ libraries. This compiler error only appears for native_posix_64, and not for native_posix.
The compiler error:
In file included from /home/hein/zephyrproject/zephyr/include/zephyr/net/socket.h:27,
from /home/hein/zephyrproject/zephyr/include/zephyr/net/sntp.h:11,
from /home/hein/zephyrproject/zephyr/samples/cpp/cpp_synchronization/src/main.cpp:135:
/home/hein/zephyrproject/zephyr/include/zephyr/net/net_ip.h:167:16: error: conflicting declaration ‘typedef size_t socklen_t’
167 | typedef size_t socklen_t;
| ^~~~~~~~~
In file included from /usr/include/c++/11/bits/atomic_wait.h:44,
from /usr/include/c++/11/bits/atomic_base.h:41,
from /usr/include/c++/11/atomic:41,
from /home/hein/zephyrproject/zephyr/samples/cpp/cpp_synchronization/src/main.cpp:134:
/usr/include/unistd.h:274:21: note: previous declaration as ‘typedef __socklen_t socklen_t’
274 | typedef __socklen_t socklen_t;
| ^~~~~~~~~
To Reproduce
Steps to reproduce the behavior:
- Apply the following patch to an existing sample
diff --git a/samples/cpp/cpp_synchronization/prj.conf b/samples/cpp/cpp_synchronization/prj.conf
index 4c99ccacbe..7c62f9419b 100644
--- a/samples/cpp/cpp_synchronization/prj.conf
+++ b/samples/cpp/cpp_synchronization/prj.conf
@@ -1,3 +1,9 @@
CONFIG_CPP=y
CONFIG_CPP_MAIN=y
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=128
+
+CONFIG_STD_CPP20=y
+CONFIG_EXTERNAL_LIBCPP=y
+CONFIG_THREAD_LOCAL_STORAGE=y
+CONFIG_CPP_MAIN=y
\ No newline at end of file
diff --git a/samples/cpp/cpp_synchronization/src/main.cpp b/samples/cpp/cpp_synchronization/src/main.cpp
index 3ccf39bbb2..51e3c172e3 100644
--- a/samples/cpp/cpp_synchronization/src/main.cpp
+++ b/samples/cpp/cpp_synchronization/src/main.cpp
@@ -130,6 +130,9 @@ void coop_thread_entry(void)
}
}
+
+#include <atomic>
+#include <zephyr/net/sntp.h>
int main(void)
{
struct k_timer timer;
- west build -p always -b native_posix_64 samples/cpp/cpp_synchronization/
- See the compiler error
Expected behavior
Expect the build to complete with zero warnings.
Impact
Potential showstopper
Environment (please complete the following information):
- Ubuntu 22.04
- Zephyr SDK 0.16
- 4b7f156
Metadata
Metadata
Assignees
Labels
area: C++area: SocketsNetworking socketsNetworking socketsarea: native portHost native arch port (native_sim)Host native arch port (native_sim)bugThe issue is a bug, or the PR is fixing a bugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bugMedium impact/importance bug