This is the mail archive of the mailing list for the libstdc++ project.

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

Re: gcc 3.0 cannot compile pooma

On Wed, Jun 06, 2001 at 03:50:06PM -0700, Benjamin Kosnik wrote:
> > It's not at all clear to me what the c_shadow headers are trying to do
> > or why they don't work.  However, closing namespaces and extern "C"
> > blocks at the _beginning_ of a header and opening them at the _end_
> > looks, at the very least, impossibly fragile.
> the extern "C" bits have to go. They add needless complexity: a patch 
> that removed them (in both math.h and bits/std_cmath.h in the c_shadow 
> directory) can be considered pre-approved.
> The namespace trickery has to remain,  however.

It seems to me that something like this should do just as well and be
less fragile.

/* cstdlib */

#include <stdlib.h>

#endif /* <cstdlib> */


/* stdlib.h */

namespace _C_stdlib_h {
#include_next "stdlib.h"

using namespace _C_stdlib_h;

namespace std {
#undef strcpy
/* ... */
  using ::_C_stdlib_h::strcpy;
  /* ... */

#ifndef __size_t_in_namespace_std
  typedef ::_C_stdlib_h::size_t size_t;
#define __size_t_in_namespace_std
  /* ... */



The separate internal namespaces for each C header are because you
don't want to drag in everything from _every_ C header just because
the user asked for everything from _one_ C header.

Note that if this works, then I don't think it's necessary to provide
shadows for C headers not specified by C++98, which makes life
considerably simpler.

Note2, that in this scheme, nonstandard typedefs in a C header will
only be aliased into the global namespace by the shadow header.  I
don't see any way around that and I think Nathan's scheme has the same

Note3, that if you liked, we could add some kind of namespace support
to the preprocessor, which could make life a lot simpler.  (E.g.
#pragma GCC prefix __foobar_ would tack __foobar_ on the beginning of
every macro defined until the next #pragma GCC prefix.  This is
probably too simple, but you get the idea.)

zw   The beginning of almost every story is actually a bone, something with
     which to court the dog, which may bring you closer to the lady.
     	-- Amos Oz, _The Story Begins_

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