clarification of intent WRT shadowing C library

Benjamin Kosnik bkoz@redhat.com
Fri Oct 27 06:50:00 GMT 2000


> | 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





More information about the Libstdc++ mailing list