autotools conversion: include the header 'config.h' in every C source file.
----- Original Nachricht ----
Von: Patrick McHardy <[email protected]> An: Giorgio Dal Molin <[email protected]> Datum: 10.07.2014 12:04 Betreff: Re: [PATCH 4/7] autotools conversion: include the header 'config.h'
in every C source file.
Quoted 10 lines · Giorgio Dal Molin
Quoted 1 line
Added an #include <
config.h> to all the C source files so that theresults
Quoted 6 lines
of the tests in the configure script are available to all the compilation units.
We could have added the include also to 'yacc_parser.y' and 'scanner.l' but we don't, because it is not strictly needed and to avoid to define the variable 'VERSION' two times.
Quoted 12 lines
src/cli.c line 16
Quoted 9 lines
src/cli.c +3
-0@@ -11,6 +11,9 @@* * Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif Do we really need those ifdefs?
Hi,
do you mean just the #ifdefs or the whole #include <config.h> ?
The config.h should be included, unless there are real problems with it; one I've found is the preprocessor variable VERSION defined in the yacc source 'src/yacc_parser.y':
it would conflict with the same variable defined in the 'config.h'.
Actually, if you just build the package under linux, using the ./configure... && make all install you will always generate / include the config.h, so the #ifdef is not strictly needed.
giorgio
Quoted 35 lines · On Thu, Jul 10, 2014 at 12:32:18PM +0200, [email protected] wrote:
----- Original Nachricht ----
Von: Patrick McHardy <[email protected]> An: Giorgio Dal Molin <[email protected]> Datum: 10.07.2014 12:04 Betreff: Re: [PATCH 4/7] autotools conversion: include the header 'config.h'in every C source file.
Quoted 10 lines · Giorgio Dal Molin
Quoted 1 line
Added an #include <
config.h> to all the C source files so that theresults
Quoted 6 lines
of the tests in the configure script are available to all the compilation units.
We could have added the include also to 'yacc_parser.y' and 'scanner.l' but we don't, because it is not strictly needed and to avoid to define the variable 'VERSION' two times.
Quoted 12 lines
src/cli.c line 16
Quoted 9 lines
src/cli.c +3
-0@@ -11,6 +11,9 @@* * Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif Do we really need those ifdefs?
Hi,
Quoted 8 lines
do you mean just the #ifdefs or the whole #include <
config.h> ?The
config.hshould be included, unless there are real problems with it; one I've found is the preprocessor variable VERSION defined in the yacc source 'src/yacc_parser.y':
it would conflict with the same variable defined in the 'config.h'.Actually, if you just build the package under linux, using the ./configure... && make all install you will always generate / include the
config.h, so the #ifdef is not strictly needed.
So let's remove them. Also I think a lot of programs are using CFLAGS to -include config.h, that might be easier.
Please change this one way or the other and address Pablo's comment and I'll merge this.
----- Original Nachricht ----
Von: Patrick McHardy <[email protected]> An: [email protected] Datum: 10.07.2014 14:52 Betreff: Re: Re: [PATCH 4/7] autotools conversion: include the header
'config.h' in every C source file.
Quoted 52 lines · On Thu, Jul 10, 2014 at 12:32:18PM +0200, [email protected] wrote:
Quoted 8 lines
----- Original Nachricht ----
Von: Patrick McHardy <[email protected]> An: Giorgio Dal Molin <[email protected]> Datum: 10.07.2014 12:04 Betreff: Re: [PATCH 4/7] autotools conversion: include the header'
config.h'Quoted 6 lines
in every C source file.
Quoted 4 lines · Giorgio Dal Molin
Quoted 1 line
Added an #include <
config.h> to all the C source files so that theresults
Quoted 1 line
of the tests in the configure script are available to all the
compilation
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
units.
We could have added the include also to 'yacc_parser.y' and
'scanner.l'
Quoted 1 line
Quoted 1 line
Quoted 1 line
but we don't, because it is not strictly needed and to avoid to
define
Quoted 7 lines
Quoted 7 lines
src/cli.c line 12
Quoted 7 lines
the variable 'VERSION' two times.
src/cli.c +0
-0@@ -11,6 +11,9 @@* * Development of this code funded by Astaro AG Quoted 8 lines
Quoted 7 lines
src/cli.c line 16
Quoted 4 lines
src/cli.c +3
-0*/ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif Do we really need those ifdefs?
Quoted 5 lines
Hi,
do you mean just the #ifdefs or the whole #include <
config.h> ?The
config.hshould be included, unless there are real problems with it;one I've found
Quoted 1 line
is the preprocessor variable VERSION defined in the yacc source
'src/yacc_parser.y':
Quoted 3 lines
it would conflict with the same variable defined in the '
config.h'.Actually, if you just build the package under linux, using the
./configure... && make all install
Quoted 1 line
you will always generate / include the
config.h, so the #ifdef is not
Quoted 8 lines
strictly needed.
So let's remove them. Also I think a lot of programs are using CFLAGS to -include
config.h, that might be easier.Please change this one way or the other and address Pablo's comment and I'll
merge this.
Hi,
Pablo's comment should already be addressed here:
http://marc.info/?l=netfilter-devel&m=140498900625610&w=4
The new patch for the config.h inclusion will be posted shortly.
giorgio
PATCH 1/1 autotools conversion: include the header 'config.h' in every C source file.
In reply to Patrick McHardyAdded an #include <config.h> to all the C source files so that the results of the tests in the configure script are available to all the compilation units.
We could have added the include also to 'yacc_parser.y' and 'scanner.l' but we don't, because it is not strictly needed and to avoid to define the variable 'VERSION' two times.
--- src/cli.c | 2 ++ src/ct.c | 2 ++ src/datatype.c | 2 ++ src/erec.c | 2 ++ src/evaluate.c | 2 ++ src/expression.c | 2 ++ src/exthdr.c | 2 ++ src/gmputil.c | 2 ++ src/main.c | 2 ++ src/meta.c | 2 ++ src/mnl.c | 2 ++ src/netlink.c | 2 ++ src/netlink_delinearize.c | 2 ++ src/netlink_linearize.c | 2 ++ src/payload.c | 2 ++ src/proto.c | 2 ++ src/rbtree.c | 2 ++ src/rule.c | 2 ++ src/segtree.c | 2 ++ src/statement.c | 2 ++ src/utils.c | 2 ++ 21 files changed, 42 insertions(+)
src/cli.c +2 -0
@@ -12,6 +12,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stdlib.h> #include <stdio.h> #include <stdarg.h>
src/ct.c +2 -0
@@ -10,6 +10,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stddef.h> #include <stdlib.h> #include <stdio.h>
src/datatype.c +2 -0
@@ -8,6 +8,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stdlib.h> #include <string.h> #include <inttypes.h>
src/erec.c +2 -0
@@ -8,6 +8,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stdio.h> #include <string.h> #include <stdarg.h>
src/evaluate.c +2 -0
@@ -8,6 +8,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stddef.h> #include <stdlib.h> #include <stdio.h>
src/expression.c +2 -0
@@ -8,6 +8,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stddef.h> #include <stdlib.h> #include <stdio.h>
src/exthdr.c +2 -0
@@ -10,6 +10,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stddef.h> #include <stdlib.h> #include <stdio.h>
src/gmputil.c +2 -0
@@ -8,6 +8,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stddef.h> #include <stdlib.h> #include <stdarg.h>
src/main.c +2 -0
@@ -8,6 +8,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stdlib.h> #include <stddef.h> #include <unistd.h>
src/meta.c +2 -0
@@ -10,6 +10,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stddef.h> #include <stdlib.h> #include <stdio.h>
src/mnl.c +2 -0
@@ -8,6 +8,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <libmnl/libmnl.h> #include <libnftnl/common.h> #include <libnftnl/ruleset.h>
src/netlink.c +2 -0
@@ -9,6 +9,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <string.h> #include <fcntl.h> #include <errno.h>
src/netlink_delinearize.c +2 -0
@@ -9,6 +9,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stdlib.h> #include <stdbool.h> #include <string.h>
src/netlink_linearize.c +2 -0
@@ -9,6 +9,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <linux/netfilter/nf_tables.h> #include <string.h>
src/payload.c +2 -0
@@ -10,6 +10,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stddef.h> #include <stdlib.h> #include <stdio.h>
src/proto.c +2 -0
@@ -9,6 +9,8 @@* */ +#include <config.h> +#include <stddef.h> #include <stdlib.h> #include <stdint.h>
src/rbtree.c +2 -0
@@ -19,6 +19,8 @@* */ +#include <config.h> +#include <rbtree.h> static void __rb_rotate_left (struct rb_node *node,struct rb_root *root)
src/rule.c +2 -0
@@ -8,6 +8,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stddef.h> #include <stdlib.h> #include <stdio.h>
src/segtree.c +2 -0
@@ -8,6 +8,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stdlib.h> #include <inttypes.h> #include <arpa/inet.h>
src/statement.c +2 -0
@@ -8,6 +8,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stddef.h> #include <stdlib.h> #include <stdio.h>
src/utils.c +2 -0
@@ -8,6 +8,8 @@* Development of this code funded by Astaro AG (http://www.astaro.com/) */ +#include <config.h> +#include <stddef.h> #include <stdlib.h> #include <stdarg.h>
Signature · 1 line
2.0.1
Pablo Neira Ayuso
maintainerQuoted 3 lines · Giorgio Dal Molin
Added an #include <
config.h> to all the C source files so that the results of the tests in the configure script are available to all the compilation units.
I think we can avoid this by passing the configuration options to the compiler via -D instead of via config.h file.
https://www.gnu.org/software/autoconf/manual/autoconf-2.65/html_node/Configuration-Headers.html
Any reason not to do it that way?
Thanks.
Quoted 11 lines · Pablo Neira Ayuso
Quoted 3 lines · Giorgio Dal Molin
Added an #include <
config.h> to all the C source files so that the results of the tests in the configure script are available to all the compilation units.I think we can avoid this by passing the configuration options to the compiler via -D instead of via
config.hfile.https://www.gnu.org/software/autoconf/manual/autoconf-2.65/html_node/Configuration-Headers.html
Any reason not to do it that way?
The compiler command line is already long enough (when choosing to look at it via make V=1) for human analysis, and distros easily add even more CFLAGS like -O,-f,-m into it. Not using config.h would make the situation worse for analysis by human.