Re: Bug#126703: g++-3.0: <stdio.h> defines _GNU_SOURCE with g++-3.0
> > > possibly include a glibc header, otherwise certain C++ programs will
> > > simply fail out of the box.
> >
> > I don't believe that this is true.
> [...]
> > > http://gcc.gnu.org/ml/libstdc++/2000-12/msg00215.html
>
> Well, there's my example. :-)
Just to make sure we are talking about the same example: You are
trying to compile
#include <stdlib.h>
#include <cstdlib>
with g++. Currently, this fails because the header files cannot
re-export symbols (starting with a failure to re-export lldiv_t).
> You are aware that this code is currently unused by default, and unused
> by Debian, right? Only one of {c,c_std,c_shadow} is used.
The same strategy applies to any setup. Please modify your installed
c++config.h to read
// Define if C99 features such as lldiv_t, llabs, lldiv should be exposed.
#ifdef __USE_ISOC99
#define _GLIBCPP_USE_C99 1
#endif
then, compile
#undef _GNU_SOURCE
#include <stdlib.h>
#include <cstdlib>
int main(){}
with the installed g++ 3. It compiles fine for me.
Now you may argue that
#undef _GNU_SOURCE
#include <stdlib.h>
#include <cstdlib>
int main(){
std::lldiv_t x;
}
won't compile anymore, with that change, since lldiv_t is not
available to the application. This is not a problem, since C++98 does
not mandate that cstdlib offers std::lldiv_t. Anybody wanting to
compile a C++ program that uses C99 features should define either
_ISOC99_SOURCE or _GNU_SOURCE.
Regards,
Martin
Reply to: