This is the mail archive of the
mailing list for the libstdc++ project.
c_compatibility headers, include_next
- To: libstdc++ at gcc dot gnu dot org, zackw at stanford dot edu, neil at daikokuya dot demon dot co dot uk
- Subject: c_compatibility headers, include_next
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Thu, 7 Jun 2001 17:51:21 -0700
Hey y'all. I have a cpp question, so I'm including the relevant folks,
with the hope that they'll be responsive.
What I'd like to do is ship a full set of "C" compatibility headers,
as per annex D of the C++ standard. These are things like <string.h>,
which include <cstring> and inject all the names in std:: into the
I've done this in my sandbox, but am having problems where:
/mnt/hd/ahimsa/bld-x86-gcc/gcc/g++ -B/mnt/hd/ahimsa/bld-x86-gcc/gcc/ -nostdinc++ -L/mnt/hd/ahimsa/bld-x86-gcc/i686-pc-linux-gnu/libstdc++-v3/src -L/mnt/hd/ahimsa/bld-x86-gcc/i686-pc-linux-gnu/libstdc++-v3/src/.libs -B/mnt/hd/ahimsa/H-x86-gcc/i686-pc-linux-gnu/bin/ -B/mnt/hd/ahimsa/H-x86-gcc/i686-pc-linux-gnu/lib/ -isystem /mnt/hd/ahimsa/H-x86-gcc/i686-pc-linux-gnu/include -ggdb3 -DDEBUG_ASSERT -ffunction-sections -fdata-sections -nostdinc++ -I/mnt/hd/ahimsa/bld-x86-gcc/i686-pc-linux-gnu/libstdc++-v3/include/i686-pc-linux-gnu -I/mnt/hd/ahimsa/bld-x86-gcc/i686-pc-linux-gnu/libstdc++-v3/include -I/mnt/hd/bliss/src.gcc/libstdc++-v3/libsupc++ -I/mnt/hd/bliss/src.gcc/libstdc++-v3/libio -I/mnt/hd/bliss/src.gcc/libstdc++-v3/testsuite /mnt/hd/bliss/src.gcc/libstdc++-v3/testsuite/17_intro/header_cstdio.cc -DDEBUG_ASSERT -lm -o ./header_cstdio
In file included from /mnt/hd/ahimsa/bld-x86-gcc/i686-pc-linux-gnu/libstdc++-v3/include/ctime:31,
The problem, in a nutshell, is that when <sys/types.h> in included, it
includes time.h and libstdc++'s "C" compatibility header <time.h> is
found and included, which then includes <ctime>, which includes
<usr/include/time.h>. The <ctime> header then expects that stuff like
struct tm will be declared and injects it into std like
The problem is that when <sys/types> ends up including
</usr/include/time.h>, struct tm isn't declared (__need_tm or whatever
isn't defined, but more importantly the "C" standard doesn't require
it to be declared in this case...) and thus.......kableweeeeee.
This can be worked around by providing "C" compatibility headers for
just string.h and math.h, which are absolutely necessary as the C++
headers change "C" signatures or use builtins and thus #define away
required names from the global namespace to prevent overloading
The question is this: is there a way to structure the "C"
compabitility headers so that
#if (we're being included by an include_next'd header)
// use "C"
# include_next <foo.h>
// use c++
# include <cfoo>
I must be going mad to even consider this, but now I'm curious.