Skip to contentSkip to conversation

autotools conversion: include the header 'config.h' in every C source file.

PATCH In review [email protected] 4 participants 6 messages Jul 10, 2014 – Jul 12, 2014 netfilter

lore
Share & tools
lore
#0 lore raw

----- 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 the

results

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

#1 lore raw
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 the

results

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.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.

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.

#2 lore raw

----- 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 the

results

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

(http://www.astaro.com/)

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.h should 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

#3 lore raw

PATCH 1/1 autotools conversion: include the header 'config.h' in every C source file.

In reply to Patrick McHardy

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.

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
index f748a0e..8943349 100644
@@ -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
index 30639b2..3bddfcb 100644
@@ -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
index 55af227..2ce2997 100644
@@ -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
index 4930085..8532470 100644
@@ -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
index 2330bbb..0c82f36 100644
@@ -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
index fa14d99..d3b4952 100644
@@ -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
index a619ecc..a980555 100644
@@ -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
index cb46445..3d22702 100644
@@ -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
index a446bc6..874cc8d 100644
@@ -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
index 80f88ff..b9db99f 100644
@@ -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
index a816106..e2b39d6 100644
@@ -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
index 2e7c572..2206914 100644
@@ -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
index 5c6ca80..1cb514f 100644
@@ -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
index 5c1b46d..7dbe99e 100644
@@ -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
index a1785a5..553597d 100644
@@ -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
index 0a37a65..9ccb8e2 100644
@@ -9,6 +9,8 @@
  *
  */
 
+#include <config.h>
+
 #include <stddef.h>
 #include <stdlib.h>
 #include <stdint.h>
src/rbtree.c +2 -0
index 325c012..c400c0d 100644
@@ -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
index a7bc6f4..a1db70f 100644
@@ -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
index 1785f64..a538670 100644
@@ -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
index 2dd3f18..03f3ddc 100644
@@ -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
index 96ff419..bf1e8dc 100644
@@ -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
#4 lore raw
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.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.

#5 lore raw
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.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?

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.