Fix usage of _GNU_SOURCE

_GNU_SOURCE must be defined before including any other (system)
header, so defining it in glib-unix.h (and hoping no one has included
anything else before that) is wrong. And the "#define _USE_GNU"
workaround for this problem in gnetworkingprivate.h is even wronger
(and still prone to failure anyway due to single-include guards).

Fix this by defining _GNU_SOURCE in config.h when building against
glibc. In theory this is bad because new releases of glibc may include
symbols that conflict with glib symbols, which could then cause
compile failures. However, most people only see new releases of glibc
when they upgrade their distro, at which point they also generally get
new releases of gcc, which have new warnings/errors to clean up
anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=649201
This commit is contained in:
Dan Winship
2011-05-01 11:17:14 -04:00
parent 33c0877adc
commit e56498ee0b
16 changed files with 11 additions and 61 deletions

View File

@@ -26,10 +26,6 @@
* system, work around it here (or better, fix the system or tell
* people to use a better one).
*/
#ifndef _GNU_SOURCE
#define _G_GNU_SOURCE_TEMPORARILY_DEFINED
#define _GNU_SOURCE
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -37,10 +33,6 @@
#include <sys/wait.h>
#include <stdlib.h>
#include <fcntl.h>
#ifdef _G_GNU_SOURCE_TEMPORARILY_DEFINED
#undef _GNU_SOURCE
#undef _G_GNU_SOURCE_TEMPORARILY_DEFINED
#endif
#include <glib.h>