template instantiation and anonymous namespaces
John (Eljay) Love-Jensen
eljay@adobe.com
Wed Jul 15 11:25:00 GMT 2009
Hi Stefan,
> As I understand it, the anonymous namespace has internal linkage...
Sort of, but not really. If you look at your object code, you will see that
the symbols in the anonymous namespace have external linkage. (But the
symbol will be mangled with a different random prefix or suffix, or perhaps
some other unique-ifying technique.)
I'm not up on the latest C++0x. Perhaps the anonymous namespaces have
external linkage is changed. The "whys and wherefores" for external linkage
with anonymous namespace -- I can't remember off the top of my head.
GUIDELINE: header files should not contain anonymous namespaces. (At the
moment, I cannot think of any exceptions to that guideline.)
Sincerely,
--Eljay
More information about the Gcc-help
mailing list