[v3] default to --disable-long-long, ctype fixes
george@moberg.com
george@moberg.com
Wed Dec 20 13:43:00 GMT 2000
So let me see if I understand this correctly. This is a problem because
C99 features are not turned on by default in glibc?
If that's the case, is it _GNU_SOURCE that has to be defined, or is
defining _ISOC99_SOURCE enough?
Here's what my copy of stdlib.h says:
#if defined __USE_ISOC9X && !defined __lldiv_t_defined
/* Returned by `lldiv'. */
__extension__ typedef struct
{
long long int quot; /* Quotient. */
long long int rem; /* Remainder. */
} lldiv_t;
# define __lldiv_t_defined 1
#endif
It appears that lldiv_t is keyed off of _ISOC99_SOURCE. If defining
_ISOC99_SOURCE is enough, could that symbol be defined during a compile
of any C++ source, by the compiler, if running on a GNU system, or will
too many people get out their shotguns and pickaxes?
I wouldn't complain too much if _ISOC99_SOURCE were defined all the
time, but I'm not too sure whether it would be a problem for a majority
of users. Since it's a year after 1999, after all, (;^) maybe this
would be OK.
Would it solve your problem?
Benjamin Kosnik wrote:
>
> Right. Sorry if I was so abrupt before.
>
> Here are the gory details for linux:
>
> This is basically a "C" header issue, as far as I'm concerned. The only
> way to get definitions like 'lldiv_t' out of stdlib.h is to pass
> _GNU_SOURCE. As this option is not passed by default, ISO-C9X features
> are turned off when a user does something like "#include <stdlib.h>" and
> then compiles like "g++ foo.cc"
>
> That case has to work.
>
> The problem comes in where libstdc++-v3 explicitly enables ISO-C99
> features in config/os/gnu-linux/bits/os_defines.h -- this is used during
> configure to probe and see what kind of ISO-C99 support is around: on
> linux, as _GNU_SOURCE is explicitly defined, lldiv_t is found in
> stdlib.h, so HAVE_LLDIV_T is defined. This makes sense. The problem is
> when a user does something like
>
> #include <stdlib.h>
> #include <cstdlib>
>
> and compiles like "g++ foo.cc"
>
> What happens: stdlib.h is parsed without ISO-C99 features, then cstdlib
> is parsed, expecting ISO-C99 features from stdlib.h, including things like
> lldiv_t. This is incorrect, and results in a compile-time failure. This is bad.
>
> Other heades are also show similar symptoms.
>
> Does this make it easier to understand why it's off by default? I agree,
> it would be nice to have it on by default. However, I don't see how
> that's possible, given the current state of C99 support in the "C" library.
>
> Ulrich, feel free to correct me if I'm way off base.
>
> -benjamin
--
George T. Talbot
<george at moberg dot com>
More information about the Libstdc++
mailing list