Added relevant POSIX headers for networking.#120
Added relevant POSIX headers for networking.#120SebastianSchildt merged 2 commits intoCOVESA:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Updates Zephyr example code to accommodate Zephyr’s header reorganization by switching socket-related includes to the new POSIX header locations, aligning with the referenced upstream Zephyr change.
Changes:
- Replace
#include <zephyr/net/socket.h>with#include <zephyr/posix/sys/socket.h>in shared/example code paths. - Remove redundant Zephyr socket header include(s) where the header is now expected to come from elsewhere.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| examples/common/common.h | Switch Zephyr socket include to POSIX sys/socket header. |
| examples/common/common.c | Remove Zephyr-specific socket include from the source include list. |
| examples/acf-can/zephyr/acf-can-bridge.c | Switch Zephyr socket include to POSIX sys/socket header and remove duplicate include. |
| examples/acf-can/acf-can-common.c | Switch Zephyr socket include to POSIX sys/socket header. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #include <netinet/in.h> | ||
| #elif defined(__ZEPHYR__) | ||
| #include <zephyr/net/socket.h> | ||
| #include <zephyr/posix/sys/socket.h> |
There was a problem hiding this comment.
On Zephyr, common.h now only includes <zephyr/posix/sys/socket.h> (and ethernet). The code in common.c uses struct sockaddr_in/struct in_addr fields and htons/htonl/INADDR_ANY, which typically come from the inet/netinet headers rather than sys/socket.h. To avoid relying on transitive includes that may change across Zephyr versions, consider also including the appropriate POSIX inet/netinet header(s) in the __ZEPHYR__ branch here.
| #include <zephyr/posix/sys/socket.h> | |
| #include <zephyr/posix/sys/socket.h> | |
| #include <zephyr/posix/netinet/in.h> | |
| #include <zephyr/posix/arpa/inet.h> |
Due to a change in Zephyr structure, we need to now specifically add headers for POSIX utilities. See zephyrproject-rtos/zephyr@ac859d0 for the corresponding Zephyr commit. Signed-off-by: Naresh Nayak <naresh.nayak@de.bosch.com>
afba478 to
86b9f2b
Compare
Signed-off-by: Naresh Nayak <naresh.nayak@de.bosch.com>
SebastianSchildt
left a comment
There was a problem hiding this comment.
Works for me 🌵
Due to a change in Zephyr structure, we need to now specifically add headers for POSIX utilities. See zephyrproject-rtos/zephyr@ac859d0 for the corresponding Zephyr commit.