Hi list,
today I fixed a header file in libosmocore:
https://gerrit.osmocom.org/c/libosmocore/+/26044
TL;DR, using OSMO_IS_{LITTLE,BIG}_ENDIAN macros without including the <osmocom/core/endian.h> header leads to empty struct definitions, and thus weird compiler warnings like 'struct `foo` has no member `bar`'.
We may want to catch missing #include of the <endian.h> automatically, so I wrote a simple script to check whether it is absent:
https://gerrit.osmocom.org/c/osmo-ci/+/26045
Below is an example of using it:
$ cd libosmocore/ $ verify_endian_header.sh $(find . -name "*.[hc]") File './include/osmocom/gsm/protocol/gsm_44_004.h' does not #include <osmocom/core/endian.h>
What's still missing is the actual integration into the build verification process. I guess there is currently no easy way other than calling this script from 'contrib/jenkins.sh' of each project?
P.S. I found out that we also have 'scripts/verify_log_statements.py' in osmo-ci.git, but we don't seem to call it anywhere?
Best regards, Vadim.
Hi Vadim,
On Sat, Oct 30, 2021 at 01:40:38AM +0300, Vadim Yanitskiy wrote:
TL;DR, using OSMO_IS_{LITTLE,BIG}_ENDIAN macros without including the <osmocom/core/endian.h> header leads to empty struct definitions, and thus weird compiler warnings like 'struct `foo` has no member `bar`'.
I think a more "automatic" solution to catch those errors is to try to build with -Wundef. For libosmocore, there is currently some fall-out with EMBEDDED (we'd have to explicitly #define EMBEDDED 0 via autoconf).
The advantage of the -Wundef approach is that it should work for all such 'forgot to include a header defining a macro' use cases, and it doesn't require an external tool for validation. Just add -Wundef to our normal build flags.