This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Declarations in anonymous namespaces
- From: aaronwl <aaronwl at dot rm-f dot net>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 25 Apr 2002 21:53:20 -0700
- Subject: Declarations in anonymous namespaces
hi,
i am not sure what the correct behavior is when a function is declared in
a anonymous namespace, but defined outside of it (is this even possible?)
for example:
#1
namespace {
void f();
}
void f() {
}
i dont know for sure, but shouldnt this cause f() to be defined with
internal linkage? since the declaration will be selected into the global
namespace, shouldnt that cause the definition to refer to it? (we cant have
two functions with the same signature..)
GCC 3.0.4 disagrees with this, and declares it with external linkage:
#1, nm: 00000000 T __Z1fv
if i define it within the namespace:
#2
namespace {
void f() {
}
}
it is mangled correctly:
00000000 T __ZN28_GLOBAL__N_mytest2.cppukuKWd1fEv
what gives? am i just plain incorrect in thinking it should have
internal linkage? if so, should GCC emit a diagnostic about this
useless declaration in an anonymous namespace?
Thanks,
AaronWL