[PATCH:libICE] Fix stdio.h include for asprintf.
Mark Kettenis
mark.kettenis at xs4all.nl
Sun Dec 19 11:41:10 PST 2010
> From: Cyril Brulebois <kibi at debian.org>
> Date: Sun, 19 Dec 2010 18:43:49 +0100
>
> asprintf is a GNU extension and one needs to define _GNU_SOURCE before
> including stdio.h. Otherwise, the build breaks this way with
>
> ---
> src/process.c | 6 ++++++
> 1 files changed, 6 insertions(+), 0 deletions(-)
>
> diff --git a/src/process.c b/src/process.c
> index 58c6894..bdeeb7f 100644
> --- a/src/process.c
> +++ b/src/process.c
> @@ -29,6 +29,12 @@ Author: Ralph Mor, X Consortium
> #ifdef HAVE_CONFIG_H
> #include <config.h>
> #endif
> +
> +#ifdef HAVE_ASPRINTF
> +#define _GNU_SOURCE
> +#include <stdio.h>
> +#endif
Generally speaking it is a bad idea to put things like this
_GNU_SOURCE define somewhere in the middle of a source code file. It
is important to do so before any include files, and do it
unconditionally.
I believe there is an autoconf macro that adds _GNU_SOURCE when
appropriate to config.h. It also makes sure the autoconf tests are
run with _GNU_SOURCE defined such that the results of the tests are
consistent with _GNU_SOURCE being defined. As long as config.h is
guaranteed to always be included first, that is probably the way to go.
More information about the xorg-devel
mailing list