Repository navigation
fix(net): guard net_posix.c, which broke every non-test build - #113
Kartikey1306 wants to merge 2 commits into
Conversation
…ilds
master does not compile:
tests/test_net.c:212:5: error: call to undeclared function 'assert';
ISO C99 and later do not support implicit function declarations
test_net.c makes ten assert() calls and includes stdio, stdlib and string
but never assert.h. It built while every test target was compiled with
NDEBUG, and embeddedos-org#104 removed that from test targets so the assertions in
these suites are real again -- which is what turned the missing include
into an error.
The include is what the file always needed; nothing else changes. Swept
the rest of tests/*.c and this is the only file that calls assert()
without including the header.
Restores the build: 34/34, and the assertions are live in the binary
rather than compiled away.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A plain `cmake -S . -B build` -- the default configuration, and what the
library job in CI runs -- does not compile:
net/src/net_posix.c:43:30: error: unknown type name 'eos_net_addr_t'
net/src/net_posix.c:73:1: error: unknown type name 'eos_socket_t'
... 30 more
eos/net.h puts every eNet declaration behind EOS_ENABLE_NET. CMakeLists.txt
defines that only for `EOS_BUILD_TESTS AND NOT EOS_PRODUCT`, but
net/src/net_posix.c is in eos_net's source list unconditionally. Built
without the feature the header contributes no types, and every definition
in the file fails.
That is why the break is invisible locally: -DEOS_BUILD_TESTS=ON is what
anyone running the suite passes, and it is the one configuration that
defines the flag.
Guard the body the way the header is guarded, so the translation unit
compiles away when the feature is off -- which is what a disabled feature
should do -- instead of failing to compile.
Both configurations now build: the default one, and -DEOS_BUILD_TESTS=ON
at 34/34 with eos_net_socket still linked into libeos_net.a.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Closing this in favour of #116, which covers the same two failures. Both PRs came from this account within a few hours — my fault for not checking first, and I'd rather leave one PR on the bug than two.
Adding the include makes those ten work only while #116 also carries the verification I could not do from this branch: the default-configuration build reproduced against unpatched Nothing in this PR is lost. |
The default build does not compile
This is what the library job in
CI — eosruns, and it is failing on master for this reason.Why
eos/net.hputs every eNet declaration behind#if EOS_ENABLE_NET.CMakeLists.txtdefines that flag only under:but
net/src/net_posix.cis ineos_net's source list unconditionally. Built without the feature, the header contributes no types and every definition in the file fails.That is also why it stays invisible locally:
-DEOS_BUILD_TESTS=ONis what anyone running the suite passes, and it happens to be the one configuration that defines the flag.Fix
Guard the body the way the header is guarded, so the translation unit compiles away when the feature is off — what a disabled feature is supposed to do — rather than failing to compile.
Verified in both configurations