This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: G++ defining _GNU_SOURCE
- To: Phil Edwards <pedwards at disaster dot jaj dot com>
- Subject: Re: G++ defining _GNU_SOURCE
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Wed, 06 Jun 2001 08:52:19 +0100
- CC: David Edelsohn <dje at watson dot ibm dot com>, Mark Mitchell <mark at codesourcery dot com>, gcc at gcc dot gnu dot org, jason_merrill at redhat dot com
- Organization: Codesourcery LLC
- References: <pedwards@disaster.jaj.com> <200106052047.QAA22192@makai.watson.ibm.com> <20010605153732.A22793@disaster.jaj.com>
Phil Edwards wrote:
>
> On Tue, Jun 05, 2001 at 04:47:28PM -0400, David Edelsohn wrote:
> > We still have no answer to the question why _GNU_SOURCE is defined
> > in cp/lang-specs.h. Its presence changes the behavior of some Free
> > Software header files. This definition was not present in gcc-2.95. This
> > macro is not defined for the GNU C Compiler, only the GNU C++ Compiler.
Here is my recollection of the problem.
On linux (at least) _GNU_SOURCE needs to be #defined from the start because the
user can write a program like
#include <stdio.h> // non-libstdc++ header
#include <iostream> // libstdc++ header
Both these includes wind up #including the idempotent /usr/include/features.h
which uses _GNU_SOURCE to turn on various bit'n'bobs that libstdc++
needs/expects. Now the above snippet will include features via stdio.h,
_before_ any libstdc++-v3 header has a chance to set _GNU_SOURCE. When
iostream is included it is too late.
I think the symptoms are more severe when -pedantic -ansi is used.
I remember preparing a patch to libstdc++'s config/os/gnu-linux/os_defines.h
to at least detect this issue, but Jason fixed it the way he did first.
Hope that helps.
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org