[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#126703: g++-3.0: <stdio.h> defines _GNU_SOURCE with g++-3.0



On Mon, Dec 31, 2001 at 01:38:06AM +0100, Matthias Klose wrote:
> Martin v. Loewis writes:
> > > > I can't see a reason for libstdc++ requiring _GNU_SOURCE except for the
> > > > desire to re-export symbols in std::, for which I would propose a
> > > > different strategy.
> > > 
> > > It would help to know why this was done in the first place; there could be
> > > other reasons.

Mail archives are our friends.  :-)  See below.


> [short question ... is this forum appropriate for this discussion or
> should we CC libstdc++@gcc.gnu.org?]

If you have questions (or better yet, patches *grin*), by all means include
the list.  However, if you do, I'd recommend /not/ cc'ing @bugs.debian.org,
because those auto-acks are awfully annoying.

Here's a super-short summary of _GNU_SOURCE.  (Now, I am not the expert on
this, so if you have more questions, /please/ contact the lists.)  We need
the symbol to be defined before including any header which could possibly
include a glibc header, otherwise certain C++ programs will simply fail
out of the box.  The C++ rules are much stricter than in C (duh), and in
order to get standard-conforming semantics out of glibc 2.2, we had to
feed it _GNU_SOURCE.  (Making glibc happier with C++ is a goal for 2.3,
I'm told.  Making libstdc++-v3 not require _GNU_SOURCE in the first place
is also a goal.)

The change was initially made here:

    http://gcc.gnu.org/ml/libstdc++/2000-12/msg00215.html

and there's an example of code which needs to not break.

Time passed.

Somebody moved the _GNU_SOURCE definition into the compiler itself, for
all platforms.  Somebody else noticed and complained here:

    http://gcc.gnu.org/ml/gcc/2001-06/msg00108.html

which started a huge thread, all instructive.  The end result was that
_GNU_SOURCE is defined by the compiler, only in C++ mode, only for those
platforms which use glibc, because otherwise code such as the example in
the first message Just Won't Work.

(This series of changes allowed us to make --enable-long-long the default
again.)

Yes, it's a mess for glibc-using platforms.  Solutions welcome.  :-)


Phil

-- 
If ye love wealth greater than liberty, the tranquility of servitude greater
than the animating contest for freedom, go home and leave us in peace.  We seek
not your counsel, nor your arms.  Crouch down and lick the hand that feeds you;
and may posterity forget that ye were our countrymen.            - Samuel Adams



Reply to: