-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile error in byteorder.h #44324
Comments
Please include further details. Which host OS, which compiler etc. All of this is requested if you fill out the bug report issue template. |
Closing for now due to insufficient information to categorize this as a bug. Please reopen with additional information if you believe this to be a bug, including steps to reproduce. |
If you look at the end of the above you see: west build -p auto -b native_posix_64 myproject |
Quite difficult to reproduce |
Just include net/socket.h in any C file and it will fail with native_posix_64 |
Does not reproduce on my machine.
|
Create and compile a C file with the two following lines and you will get the error: #include <net/socket.h> |
|
On my build setup (Ubuntu 20.04, kernel 5.4, gcc 9.4, libglib2.0-dev:2.64.6-1~ubuntu20.04.4) the |
We are using a common code base on multiple platforms. The net/socket is included by a special zephyr porting layer. byteswap.h is included by the generic code. If you look at my initial comments at the top of this thread, we did not have this problem until recently so something changed in zephyr that broke this. |
Why did you assign me to this? It's not a networking problem. |
@surfskidude What version of Zephyr, which commit are you using as base? |
@aescolar I assigned you because it is a native posix issue |
.. or something changed in your underlying platform, etc. Notice how @de-nordic carefully specified their platform. It would really help if you could do the same |
No, no changes were made to our code or build. I did a pull a few days ago so it's a recent Zephyr release. I have no idea what the old working Zephyr release version was, but it did work. |
You may be convinced of that, and you are probably right, but I am trying to explain the difference between 1. you being right and 2. you convincing the upstream Zephyr developers that you are right by providing them with an example that they can actually reproduce instead of just repeating yourself ad nauseam. |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
For what it's worth, I encountered the same error message when compiling sections of the zephyr codebase on linux x64, gcc 9.4.0 (not using Zephyr SDK). By comparing compile arguments between standard zephyr / west builds for If I compile without
With |
Hello, Since the posix native target is not that crucial for me, I'll just go with qemu. However, the problem still persists. |
For those facing this issue, and until it is fixed in Zephyr (where it should): One workaround which may work out of the box for you is to target native_sim instead of native_posix and select one of the embedded C libraries (for ex. CONFIG_PICOLIBC=y). |
__bswap_ in zephyr/sys/byteorder.h conflicts with __bswap_ in host's byteswap.h. byteswap.h from host compiler used in posix_native_64 boards causes a compilation issue. This commit renames __bswap_ to BSWAP_ to prevent collision. Before this commit a compilation error can be created by adding #include <byteswap.h> to samples/net/sockets/echo/src/socket_echo.c This does not change external API to byteorder.h, but does change internal implementation which some other source files depend on. Replaced manual byteswap operations in devmem_service.c with APIs from byteorder.h which automatically converts to CPU endianess when necessary. Fixes zephyrproject-rtos#44324 Signed-off-by: Jonathan Hamberg <[email protected]>
__bswap_ in zephyr/sys/byteorder.h conflicts with __bswap_ in host's byteswap.h. byteswap.h from host compiler used in posix_native_64 boards causes a compilation issue. This commit renames __bswap_ to BSWAP_ to prevent collision. Before this commit a compilation error can be created by adding #include <byteswap.h> to samples/net/sockets/echo/src/socket_echo.c This does not change external API to byteorder.h, but does change internal implementation which some other source files depend on. Replaced manual byteswap operations in devmem_service.c with APIs from byteorder.h which automatically converts to CPU endianess when necessary. Fixes #44324 Signed-off-by: Jonathan Hamberg <[email protected]>
Discussed in #44190
Originally posted by surfskidude March 24, 2022
I cloned the latest today and I got a compile error when I compiled my existing code, which includes net/socket.h
In file included from /home/build/zephyrproject/zephyr/include/net/net_ip.h:27,
from /home/build/zephyrproject/zephyr/include/net/socket.h:27,
/home/build/zephyrproject/zephyr/include/sys/byteorder.h:22:36: error: expected declaration specifiers or ‘...’ before ‘(’ token
22 | #define __bswap_16(x) ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))
| ^
/home/build/zephyrproject/zephyr/include/sys/byteorder.h:26:36: error: expected declaration specifiers or ‘...’ before ‘(’ token
26 | #define __bswap_32(x) ((uint32_t) ((((x) >> 24) & 0xff) |
| ^
/home/build/zephyrproject/zephyr/include/sys/byteorder.h:36:36: error: expected declaration specifiers or ‘...’ before ‘(’ token
36 | #define __bswap_64(x) ((uint64_t) ((((x) >> 56) & 0xff) |
| ^
Build:
west build -p auto -b native_posix_64 myproject
The text was updated successfully, but these errors were encountered: