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: Sample conformant, clean <c...> headers

On Mon, 04 Jun 2001, scott snyder wrote:
> The problem i see is that the following test doesn't seem to work
> (with the 20010529 version of gcc 3.0):
> -------------------------------------
> #include <cctype>
> #include <ctype.h>
> using namespace std;

This is exactly the same problem as PR 2989 that sent me
scurrying yesterday.

> Am i missing something here?

Yes, the complete fix.

There has to be three parts:  the std_cctype.h header declaring the
names in std::, the that defines the names in terms of libC,
and a ctype.h that injects the std:: names into the global namespace.

What you're missing is this third header, the "Appendix D" header, which is
kinda like the one you (Scott) proposed.  It's job is to forward the existing
libC header (cctype.h in this case), replacing the existing C++ standard
names with "using ::std::xxx" statements.  I guess to do it right would mean,
well, doing what the existing c_std headers do with all the defines and undefs.
That's necessary so all the nonstandard names don't disappear and break
existing programs.

This isn't like the existing c_std headers or the c_shadow headers, though,
since the libC headers continue to live in the global namespace.  There's
no worry about subincluded headers, ambiguous name conflicts, or undefined
symbols.  The only problems arise when the libC headers do funny things
with macro names.

I have a patch for <cstring> and friends I can post tonight once I work out
a build issue that cropped up during last night's bootstrap.  I figure start
with that header since it's the most urgent (PRs 2767, 2977, 2989, 2992 at
least).  The only other header that might have as many problems is <cwchar>,
and it's got other issues to say the least.

Further critique is welcome.

Stephen M. Webb

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