[C++ PATCH] Fix extern "C" function and namespace handling

Kriang Lerdsuwanakij lerdsuwa@scf.usc.edu
Tue Oct 10 21:24:00 GMT 2000

On Sun, 8 Oct 2000, brent verner wrote:

> namespace _C_ {
>   extern "C" int abs(int a);
> }
> namespace std {
>   inline int abs(int a){ return a >= 0 ? a : - a; }   // error

I believe we need extern "C" in the above declaration.  The standard
mentions in 7.5 para 6 that

  ... Two declarations for an object with C language linkage with the
  same name (ignoring the namespace names that qualify it) that
  appear in different namespace scopes refer to the same object. ...

Without extern "C" in the second declaration, I think this is a
separate function.  

My earlier patch contains a bug that makes the above code fails when
extern "C" is added.  It should work with the revised patch I just


More information about the Gcc-patches mailing list