function __attribute__ for non-external linkage?
John Love-Jensen
eljay@adobe.com
Wed May 16 16:16:00 GMT 2007
Hi everyone,
Help!
If I have a Foo.cpp file with this...
static int Foo()
{
return 0;
}
... I know that the Foo function has local linkage to the Foo.o translation
unit.
And that this...
namespace
{
int Foo()
{
return 0;
}
}
... does *NOT* provide local linkage for Foo in the Foo.o translation unit,
rather Foo has external linkage.
(I presume D&E C++ covers why anonymous namespaces have external linkage,
but I don't recall off the top of my head, and I don't have D&E C++
available at the moment. Probably something deep in the bowels of C++ which
makes it have that linkage by default. Maybe RTTI related. I don't know.)
Foo is name-mangled in a (hopefully) unique manner to make it effectively
non-linkable outside of the translation unit.
I can get the benefits of both facilities and do...
namespace
{
static int Foo()
{
return 0;
}
}
So far so good. So here's my problem: how can I get local linkage to a
translation unit of a class's methods?
namespace
{
class Bar
{
public:
void Quux(); // <-- how to make this have non-external/local linkage?
};
}
I don't want module linkage, I want translation unit local linkage.
I presume it's some sort of __attribute__ tag, maybe
__attribute((visibility("SomethingGoesHere")))?
Thanks,
--Eljay
More information about the Gcc-help
mailing list