This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
Re: clarification of intent WRT shadowing C library
- To: Gabriel Dos Reis <Gabriel dot Dos-Reis at cmla dot ens-cachan dot fr>
- Subject: Re: clarification of intent WRT shadowing C library
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Fri, 27 Oct 2000 06:50:18 -0700 (PDT)
- cc: libstdc++ at sources dot redhat dot com, ncm at zembu dot com, jason at cygnus dot com
> | Where the first option (designated by // 1) is the preferred solution,
> | as this explicitly makes the std::sin refer to the extern "C"
> | function.
>
> Well, I see Jason's point but I'm not comfortble with it. We should
> proceed in a way so that <cxxx> hearders don't dump C function names
> in the global scope. That is why I'm favouring the _C_legacy namespace
> solution. Yes, it is frustrating the library is not yet functionning
> out of box. Let's try hard.
Yes, this should be the preference. The small matter of implementation
details are non-trivial, however, and have been worked on for quite some
time.....
Jason, can you expand and provide commentary on the three options? I
think this would be helpful for everyone concerned. In particular, the
difference between
extern "C" foo
and
using ::foo
Note that (just in cmath) I'm unable to use the extern "C" declarations
for all the functions:
#if 0
extern "C" double pow(double __x, double __y);
extern "C" double pow(double, int);
#endif
using ::pow;
I can see no other way around this than the using declaration...
> acos(double __x) { return _C_legacy::acos(double); }
(_C_legacy not a namespace in the implementation I was talking about....)
In anycase, it doesn't change things: the extern "C" stuff should still
be used.
ie
extern "C" double acos(double);
-benjamin