diff options
author | Thomas Haller <thaller@redhat.com> | 2023-08-25 13:36:30 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-08-25 14:59:19 +0200 |
commit | b4add075c1283151d0514cf0052f9184e9e073df (patch) | |
tree | 7798c59dbe1ec7b982f7adcd4a6357aa436b20d3 /src/proto.c | |
parent | 19231d4c896571fea397d43568c4b3562969c7e2 (diff) |
src: add <nft.h> header and include it as first
<config.h> is generated by the configure script. As it contains our
feature detection, it want to use it everywhere.
Likewise, in some of our sources, we define _GNU_SOURCE. This defines
the C variant we want to use. Such a define need to come before anything
else, and it would be confusing if different source files adhere to a
different C variant. It would be good to use autoconf's
AC_USE_SYSTEM_EXTENSIONS, in which case we would also need to ensure
that <config.h> is always included as first.
Instead of going through all source files and include <config.h> as
first, add a new header "include/nft.h", which is supposed to be
included in all our sources (and as first).
This will also allow us later to prepare some common base, like include
<stdbool.h> everywhere.
We aim that headers are self-contained, so that they can be included in
any order. Which, by the way, already didn't work because some headers
define _GNU_SOURCE, which would only work if the header gets included as
first. <nft.h> is however an exception to the rule: everything we compile
shall rely on having <nft.h> header included as first. This applies to
source files (which explicitly include <nft.h>) and to internal header
files (which are only compiled indirectly, by being included from a source
file).
Note that <config.h> has no include guards, which is at least ugly to
include multiple times. It doesn't cause problems in practice, because
it only contains defines and the compiler doesn't warn about redefining
a macro with the same value. Still, <nft.h> also ensures to include
<config.h> exactly once.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/proto.c')
-rw-r--r-- | src/proto.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/proto.c b/src/proto.c index edf99e84..eb9c3ea1 100644 --- a/src/proto.c +++ b/src/proto.c @@ -9,6 +9,8 @@ * */ +#include <nft.h> + #include <stddef.h> #include <stdlib.h> #include <stdint.h> |