This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Anonymous Namespaces


Gabriel Dos Reis wrote:
> | > Yes because that is not the way C++ works, anonymous namespaces only
> | > give an unique name for that translation unit and that is it; it does
> | > not change the linkage of the symbol at all.
> |
> | Is there any harm is doing so?

> Yes. The second phase of two-phase name lookup ignores functions with
> internal linkages.  Also, entities with internal linkage cannot be
> used as template arguments.

With the LLVM G++ front-end, all entities declared in an anonymous
namespace are emitted with internal linkage, including any related RTTI
info, vtables, etc.

This has absolutely no effect on the front-end, we handle it in our
version of "expand".

If you want, you can play with this in the LLVM demo page:
http://llvm.cs.uiuc.edu/demo

but make sure that you reference things in the anonymous namespace or they
will be deleted entirely, eg:

namespace {
  int X;
}
void *Ref = &X;   // Do not DCE X.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/


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