[augeas-devel] [PATCH] Include <config.h> early, so its _GNU_SOURCE definition takes effect.

Jim Meyering jim at meyering.net
Thu Oct 16 16:47:41 UTC 2008


Hi,

I noticed warnings that might even matter on some systems.
This fixes it.

>From 5fa2714b34cefecc725b7476650c6b40154f7bc4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Sun, 12 Oct 2008 18:13:46 +0200
Subject: [PATCH] Include <config.h> early, so its _GNU_SOURCE definition takes effect.

* src/lexer.l (%top{...}): Include <config.h> here, not in %{...}.
Otherwise, the flex-emitted inclusion of <string.h> would
precede the definition of _GNU_SOURCE, rendering it useless.
This also avoids warnings about strndup being undeclared.
Don't include <string.h> explicitly, since flex already does that.
---
 src/lexer.l |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/lexer.l b/src/lexer.l
index d754a9b..e20be7f 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -5,10 +5,13 @@
 %option warn nodefault
 %option outfile="lex.yy.c" prefix="augl_"

-%{
+%top{
+/* config.h must precede flex's inclusion of <stdio.h>
+   in order for its _GNU_SOURCE definition to take effect.  */
 #include <config.h>
-#include <string.h>
+}

+%{
 #include "syntax.h"

 typedef struct info YYLTYPE;
--
1.6.0.2.514.g23abd3




More information about the augeas-devel mailing list