This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
__attribute__(visibility("default"))) and nested structures
- From: Paul Belanger <paulirino at gmail dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 24 Aug 2018 13:49:15 -0400
- Subject: __attribute__(visibility("default"))) and nested structures
Hello,
When I write classes in C++ and use the Pimpl idiom, I generally set
the structure up like so:
Foo.hpp
-------
class Foo
{
public:
Foo();
~Foo();
void method1();
void method2();
private:
struct impl;
std::unique_ptr<impl> p;
};
Foo.cpp
-------
struct Foo::impl
{
method1()
{
....
}
method2()
{
...
}
private_thing()
{
...
}
}
Foo::Foo():p(make_unique<impl>()){}
Foo::~Foo(){}
void Foo::method1(){ p->method1();}
void Foo::method2(){ p->method2();}
I'd like to hide some of the symbols for the implementation, so I
compile with -fvisibility=hidden and add
__attribute__((visibility("default"))) to the "class Foo" definintion.
My question is whether the visibility attribute applies to the methods
of the nested impl struct and makes all members visible or whether
they stay hidden.
Thanks,
Paul B.