From eda8202cf8db49bc2e64c056f207f909d1653b51 Mon Sep 17 00:00:00 2001
From: Dmitri Pal <dpal@redhat.com>
Date: Sun, 23 Dec 2012 13:03:00 -0500
Subject: [PATCH 3/8] [INI] Fixing headers

Move GNU_SOUCE definition to configure.ac
Change all headers to use config.h.
Move config.h to the top.
Remove errno.h if it is not needed.
---
 basicobjects/simplebuffer.c      |    4 +---
 basicobjects/simplebuffer_ut.c   |    2 +-
 collection/collection.c          |    3 +--
 collection/collection_cmp.c      |    3 +--
 collection/collection_cnv.c      |    3 +--
 collection/collection_iter.c     |    3 +--
 collection/collection_queue.c    |    1 +
 collection/collection_queue_ut.c |    3 +--
 collection/collection_stack.c    |    1 +
 collection/collection_stack_ut.c |    3 +--
 collection/collection_tools.c    |    2 +-
 collection/collection_ut.c       |    2 +-
 configure.ac                     |    1 +
 dhash/dhash.c                    |    1 +
 ini/ini_comment.c                |    3 +--
 ini/ini_comment_ut.c             |    2 +-
 ini/ini_config.c                 |    3 +--
 ini/ini_config_ut.c              |    1 +
 ini/ini_configobj.c              |    3 +--
 ini/ini_fileobj.c                |    3 +--
 ini/ini_get_array.c              |    3 +--
 ini/ini_get_array_valueobj.c     |    3 +--
 ini/ini_get_value.c              |    3 +--
 ini/ini_get_valueobj.c           |    3 +--
 ini/ini_list.c                   |   12 +-----------
 ini/ini_list_valueobj.c          |    3 +--
 ini/ini_metadata.c               |    3 +--
 ini/ini_parse.c                  |    3 +--
 ini/ini_parse_ut.c               |    2 +-
 ini/ini_print.c                  |    4 +---
 ini/ini_serialize.c              |    3 +--
 ini/ini_valueobj.c               |    3 +--
 ini/ini_valueobj_ut.c            |    3 +--
 path_utils/path_utils_ut.c       |    2 +-
 refarray/ref_array.c             |    3 +--
 refarray/ref_array_ut.c          |    3 +--
 36 files changed, 36 insertions(+), 67 deletions(-)

diff --git a/basicobjects/simplebuffer.c b/basicobjects/simplebuffer.c
index b47d6b69c6b226bbbdccbecce262009760eb65c9..1e7b3fbc857c341fb784e018f84a551c19799be9 100644
--- a/basicobjects/simplebuffer.c
+++ b/basicobjects/simplebuffer.c
@@ -17,8 +17,7 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
-#define _GNU_SOURCE
+#include "config.h"
 #include <errno.h>      /* for errors */
 #include <stdlib.h>     /* for free() */
 #include <unistd.h>     /* for write() */
@@ -26,7 +25,6 @@
 
 #include "simplebuffer.h"
 #include "trace.h"
-#include "config.h"
 
 /* End line string */
 #define ENDLNSTR "\n"
diff --git a/basicobjects/simplebuffer_ut.c b/basicobjects/simplebuffer_ut.c
index 61272dac848674db50adea7d516bfb76770f5eaa..ba9d172856262fe9ca34abf0dd702c1d305544c9 100644
--- a/basicobjects/simplebuffer_ut.c
+++ b/basicobjects/simplebuffer_ut.c
@@ -17,10 +17,10 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/stat.h>
diff --git a/collection/collection.c b/collection/collection.c
index d836aa42340fa4cff828d684da3c228092d3a437..fa33cb84fe3946104b34110dcf39a438d0f3432f 100644
--- a/collection/collection.c
+++ b/collection/collection.c
@@ -19,13 +19,12 @@
     along with Collection Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <ctype.h>
 #include <time.h>
-#include "config.h"
 #include "trace.h"
 
 /* The collection should use the real structures */
diff --git a/collection/collection_cmp.c b/collection/collection_cmp.c
index c1f9017d0b0623ea40f67fe6b787b72925a4da12..61d2fccd6118094cca0748a608b18b8996a0afe2 100644
--- a/collection/collection_cmp.c
+++ b/collection/collection_cmp.c
@@ -19,13 +19,12 @@
     along with Collection Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <ctype.h>
 #include <time.h>
-#include "config.h"
 #include "trace.h"
 
 /* The collection should use the real structures */
diff --git a/collection/collection_cnv.c b/collection/collection_cnv.c
index e9ca05dbd8b576d0ac68a2f3ec57ecee4853e4d6..c38f859638289dd91c6eddecc5cc41713eadfe21 100644
--- a/collection/collection_cnv.c
+++ b/collection/collection_cnv.c
@@ -21,10 +21,9 @@
     along with Collection Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <string.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <ctype.h>
 #include <time.h>
 #include "trace.h"
diff --git a/collection/collection_iter.c b/collection/collection_iter.c
index f3735d7d1bbde83ad593e89304ed218fddf5354c..9e0413c8b6846437cfed0c9fff0759a3505b2d0a 100644
--- a/collection/collection_iter.c
+++ b/collection/collection_iter.c
@@ -19,13 +19,12 @@
     along with Collection Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <ctype.h>
 #include <time.h>
-#include "config.h"
 #include "trace.h"
 
 /* The collection should use the real structures */
diff --git a/collection/collection_queue.c b/collection/collection_queue.c
index adac8ee672a7a9c8c85eaa6c375040cbbe3c6ade..91b709938a01a4aee7686ac54c6e37db1cfd83b8 100644
--- a/collection/collection_queue.c
+++ b/collection/collection_queue.c
@@ -19,6 +19,7 @@
     along with Collection Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "config.h"
 #include <stdlib.h>
 #include <errno.h>
 #include "collection_queue.h"
diff --git a/collection/collection_queue_ut.c b/collection/collection_queue_ut.c
index fbe6ea382bbb58c3117bf15026eb4a6740331d06..c4f7a68b2b927fff5d89c26cbf896f20413824b2 100644
--- a/collection/collection_queue_ut.c
+++ b/collection/collection_queue_ut.c
@@ -19,10 +19,9 @@
     along with Collection Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
-#include <errno.h>
 #define TRACE_HOME
 #include "trace.h"
 #include "collection_queue.h"
diff --git a/collection/collection_stack.c b/collection/collection_stack.c
index 509df511350f6cfd5b8ffcc9b949ada5f7961cff..50ac531afebc7c79c975bddb620c155561b5e9ba 100644
--- a/collection/collection_stack.c
+++ b/collection/collection_stack.c
@@ -19,6 +19,7 @@
     along with Collection Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "config.h"
 #include <stdlib.h>
 #include <errno.h>
 #include "collection_stack.h"
diff --git a/collection/collection_stack_ut.c b/collection/collection_stack_ut.c
index e0633b7b76450b8dbbf1b04bd258302b23fa70f9..9c25308fa878430f46fc7c84cf3500e3eb1b6086 100644
--- a/collection/collection_stack_ut.c
+++ b/collection/collection_stack_ut.c
@@ -19,10 +19,9 @@
     along with Collection Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
-#include <errno.h>
 #define TRACE_HOME
 #include "trace.h"
 #include "collection_stack.h"
diff --git a/collection/collection_tools.c b/collection/collection_tools.c
index b7f30d2545d153653c2756723bd7f7663e627a88..54d96c3a32171e97c269ca21df79f7f6a122171c 100644
--- a/collection/collection_tools.c
+++ b/collection/collection_tools.c
@@ -19,7 +19,7 @@
     along with Collection Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
+#include "config.h"
 #include <stdio.h>
 #include <malloc.h>
 #include <errno.h>
diff --git a/collection/collection_ut.c b/collection/collection_ut.c
index c34cd36ba9e009429135cf2e2b65ab4133accc22..26928794fc737eb2d622275e1bcaef93323b52cd 100644
--- a/collection/collection_ut.c
+++ b/collection/collection_ut.c
@@ -19,7 +19,7 @@
     along with Collection Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
diff --git a/configure.ac b/configure.ac
index 2e22e8a6aaac271dfa4841c17f98411967e09fd9..902ed86d237fe57d37e89424dbc79252b2d87908 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,6 +4,7 @@ AC_INIT([ding-libs],
         [sssd-devel@lists.fedorahosted.org])
 AC_CONFIG_SRCDIR([README])
 AC_CONFIG_AUX_DIR([build])
+AC_GNU_SOURCE
 AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AC_PROG_CC
 AC_PROG_LIBTOOL
diff --git a/dhash/dhash.c b/dhash/dhash.c
index efd7c8df2051cd8336d6876c393dc5aec6e9834b..8f7ea2dddfd4d92cf24306ace93295a443ea3a84 100644
--- a/dhash/dhash.c
+++ b/dhash/dhash.c
@@ -40,6 +40,7 @@
 /******************************* Include Files *******************************/
 /*****************************************************************************/
 
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
diff --git a/ini/ini_comment.c b/ini/ini_comment.c
index 6b56d0282e956777a2c4e1edfc21aa64f4536a32..3d255628b070a1fe0544d0a7dcb072fb5fa322f4 100644
--- a/ini/ini_comment.c
+++ b/ini/ini_comment.c
@@ -19,11 +19,10 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <errno.h>
 #include <string.h>
 #include <ctype.h>
-#include "config.h"
 #include "trace.h"
 #include "ref_array.h"
 #include "simplebuffer.h"
diff --git a/ini/ini_comment_ut.c b/ini/ini_comment_ut.c
index 3d017908aa0c785735889f58e816942192bf4727..eb463600c3d6d30204b3eea83a0a0d28fa80d83a 100644
--- a/ini/ini_comment_ut.c
+++ b/ini/ini_comment_ut.c
@@ -19,9 +19,9 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
-#include <errno.h>
 #include <stdlib.h>
 #define TRACE_HOME
 #include "trace.h"
diff --git a/ini/ini_config.c b/ini/ini_config.c
index f1e7cfd72c181de42c421388734680d4117579f8..4265f387d2c45694db04ec6669fb2dcb2343285e 100644
--- a/ini/ini_config.c
+++ b/ini/ini_config.c
@@ -20,12 +20,11 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <ctype.h>
-#include "config.h"
 #include "trace.h"
 #include "collection.h"
 #include "collection_tools.h"
diff --git a/ini/ini_config_ut.c b/ini/ini_config_ut.c
index 6c2e986fa10d73ca0e126507bd1a1cbcdc49c20c..34b395ba44aeeace3496d806d44929bedb3d25fe 100644
--- a/ini/ini_config_ut.c
+++ b/ini/ini_config_ut.c
@@ -19,6 +19,7 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "config.h"
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/ini/ini_configobj.c b/ini/ini_configobj.c
index e42d4d42d52187273d1b36201d2a8968333118bc..88b0279870a83c8af42c1b03e85f5f0d0b0200cf 100644
--- a/ini/ini_configobj.c
+++ b/ini/ini_configobj.c
@@ -19,12 +19,11 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
-#include "config.h"
 #include "trace.h"
 #include "collection.h"
 #include "ini_config_priv.h"
diff --git a/ini/ini_fileobj.c b/ini/ini_fileobj.c
index 1410a9008f1613d9e302e4302c2ea2d2e7bb7dbf..c120180a50cd4048d393aad8b3290cfe15af749c 100644
--- a/ini/ini_fileobj.c
+++ b/ini/ini_fileobj.c
@@ -19,11 +19,10 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
-#include "config.h"
 #include "trace.h"
 #include "ini_defines.h"
 #include "ini_configobj.h"
diff --git a/ini/ini_get_array.c b/ini/ini_get_array.c
index b2cbfacf91a87c2d807e2499021d3cdbfe36755c..30ed423e58ecc7d3d7c4824224a662e412b2c5d4 100644
--- a/ini/ini_get_array.c
+++ b/ini/ini_get_array.c
@@ -20,14 +20,13 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <locale.h>
-#include "config.h"
 #include "trace.h"
 #include "collection.h"
 #include "collection_tools.h"
diff --git a/ini/ini_get_array_valueobj.c b/ini/ini_get_array_valueobj.c
index 03fdd6034d69b705e1cf01ca567cb01eb48707ab..5be01aa8fdeac92e7464d90d65b1ed7ac5953234 100644
--- a/ini/ini_get_array_valueobj.c
+++ b/ini/ini_get_array_valueobj.c
@@ -20,14 +20,13 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <locale.h>
-#include "config.h"
 #include "trace.h"
 #include "collection.h"
 #include "collection_tools.h"
diff --git a/ini/ini_get_value.c b/ini/ini_get_value.c
index f31077f119f04d32bbc923f483f21e3d897c3b45..0afadd01004f15fd25b6a1fdb800c48b2d86af56 100644
--- a/ini/ini_get_value.c
+++ b/ini/ini_get_value.c
@@ -20,13 +20,12 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <ctype.h>
-#include "config.h"
 #include "trace.h"
 #include "collection.h"
 #include "collection_tools.h"
diff --git a/ini/ini_get_valueobj.c b/ini/ini_get_valueobj.c
index a1fa19bb903476ee9778ec5f03976b0b2a7ec542..a7efe95bee97702905e2b17dbd85ad29d815a6e4 100644
--- a/ini/ini_get_valueobj.c
+++ b/ini/ini_get_valueobj.c
@@ -20,13 +20,12 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <ctype.h>
-#include "config.h"
 #include "trace.h"
 #include "collection.h"
 #include "collection_tools.h"
diff --git a/ini/ini_list.c b/ini/ini_list.c
index 95894a153ebcaa09aaf4ea1f979cd30be4c3ce87..5fd0460ec64a29b667a809cfd193d699ec414d1b 100644
--- a/ini/ini_list.c
+++ b/ini/ini_list.c
@@ -20,19 +20,9 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <errno.h>
-/*
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <locale.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <limits.h>
-*/
-#include "config.h"
 #include "trace.h"
 #include "collection.h"
 #include "collection_tools.h"
diff --git a/ini/ini_list_valueobj.c b/ini/ini_list_valueobj.c
index 8df6a1804e8046a72271d8a4fe71f9046bde368f..bc94072f1651bbc839b36203e847b6d720268bd5 100644
--- a/ini/ini_list_valueobj.c
+++ b/ini/ini_list_valueobj.c
@@ -20,10 +20,9 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <errno.h>
-#include "config.h"
 #include "trace.h"
 #include "collection.h"
 #include "collection_tools.h"
diff --git a/ini/ini_metadata.c b/ini/ini_metadata.c
index f6d35453ef1ff377f16048b8a3172c7166358f9c..ae36b72ecb542370a3768d228b391a87da5086ea 100644
--- a/ini/ini_metadata.c
+++ b/ini/ini_metadata.c
@@ -19,12 +19,11 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <errno.h>
-#include "config.h"
 #include "collection.h"
 #include "collection_tools.h"
 #include "trace.h"
diff --git a/ini/ini_parse.c b/ini/ini_parse.c
index 9e81f2d2ecb49b56ac5501ad781f6fa96dab19cd..5690c2c2df75d82ed2bcedcbb8842973d53250ab 100644
--- a/ini/ini_parse.c
+++ b/ini/ini_parse.c
@@ -19,14 +19,13 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <errno.h>
 #include <string.h>
 #include <ctype.h>
 /* For error text */
 #include <libintl.h>
 #define _(String) gettext (String)
-#include "config.h"
 #include "trace.h"
 #include "ini_defines.h"
 #include "ini_valueobj.h"
diff --git a/ini/ini_parse_ut.c b/ini/ini_parse_ut.c
index e743eae6b4f16fcd3f85109c7d25cca8171f5522..5bf45b4dfe9a8d7795e5efd7143954e97acbef90 100644
--- a/ini/ini_parse_ut.c
+++ b/ini/ini_parse_ut.c
@@ -19,6 +19,7 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
@@ -30,7 +31,6 @@
 #include "ini_config_priv.h"
 #include "simplebuffer.h"
 #include "path_utils.h"
-#include "config.h"
 #define TRACE_HOME
 #include "trace.h"
 #include "collection_tools.h"
diff --git a/ini/ini_print.c b/ini/ini_print.c
index 1128b70342fe5b1c5d8564b90f209470dd8e0bad..d2d01c1aadd494aa3bd7a840a115a1ec9b612a7a 100644
--- a/ini/ini_print.c
+++ b/ini/ini_print.c
@@ -19,10 +19,8 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <errno.h>
 #include "config.h"
+#include <stdio.h>
 /* For error text */
 #include <libintl.h>
 #define _(String) gettext (String)
diff --git a/ini/ini_serialize.c b/ini/ini_serialize.c
index 7a53f29e4d12fd49c872fd321daf0e0ea65e2b94..dcda5acc32973c261391bdb59935c6c5aa35efc6 100644
--- a/ini/ini_serialize.c
+++ b/ini/ini_serialize.c
@@ -19,12 +19,11 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
-#include "config.h"
 #include "simplebuffer.h"
 #include "collection.h"
 #include "ini_valueobj.h"
diff --git a/ini/ini_valueobj.c b/ini/ini_valueobj.c
index 6d4dc1fcad029f92ad065e58b140f8e9940f2a0b..bee7688d8fad89caefe60f5ee403d21f531fb4f4 100644
--- a/ini/ini_valueobj.c
+++ b/ini/ini_valueobj.c
@@ -19,11 +19,10 @@
     along with INI Library.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
-#include "config.h"
 #include "simplebuffer.h"
 #include "ref_array.h"
 #include "ini_comment.h"
diff --git a/ini/ini_valueobj_ut.c b/ini/ini_valueobj_ut.c
index a35b23920843603d7e8009fe565febb6eb13557d..eb7937c4a17239a5e526b7b4f7c814bd91e0492c 100644
--- a/ini/ini_valueobj_ut.c
+++ b/ini/ini_valueobj_ut.c
@@ -17,7 +17,7 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <errno.h>  /* for errors */
 #include <stdint.h>
 #include <stdio.h>
@@ -27,7 +27,6 @@
 
 #include "ini_valueobj.h"
 #include "ini_defines.h"
-#include "config.h"
 #define TRACE_HOME
 #include "trace.h"
 
diff --git a/path_utils/path_utils_ut.c b/path_utils/path_utils_ut.c
index 174e02da37992039bab0d424f328c442bd6f5fa4..cdbdf33e171333fa10e5c462e6d955fe465b5bd6 100644
--- a/path_utils/path_utils_ut.c
+++ b/path_utils/path_utils_ut.c
@@ -20,7 +20,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE /* asprintf */
+#include "config.h"
 
 #include <check.h>
 #include <stdlib.h>
diff --git a/refarray/ref_array.c b/refarray/ref_array.c
index 393f236c901c637bfe67901b2220cf2207f62287..273ac4fa6bc7c9ef4b1219f1c536fbc05eca6611 100644
--- a/refarray/ref_array.c
+++ b/refarray/ref_array.c
@@ -17,7 +17,7 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <errno.h>  /* for errors */
 #include <stdint.h>
 #include <malloc.h>
@@ -25,7 +25,6 @@
 #include <stdio.h>
 
 #include "ref_array.h"
-#include "config.h"
 #include "trace.h"
 
 /* The structure used in referenced array */
diff --git a/refarray/ref_array_ut.c b/refarray/ref_array_ut.c
index fc9b55738fc388223c5176977b3945fa85b3f2fd..343b7faa8862797306d836759ebc2b54bd61de2e 100644
--- a/refarray/ref_array_ut.c
+++ b/refarray/ref_array_ut.c
@@ -17,7 +17,7 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <errno.h>  /* for errors */
 #include <stdint.h>
 #include <stdio.h>
@@ -25,7 +25,6 @@
 #include <stdlib.h>
 
 #include "ref_array.h"
-#include "config.h"
 #define TRACE_HOME
 #include "trace.h"
 
-- 
1.7.1

