This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: G++ defining _GNU_SOURCE


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]