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] |
Daniel Jacobowitz wrote:
This doesn't make a lick of sense to me. If the type is hidden, how on earth can it get a member function _of that type_ from another library? That library would, by definition, have to have a type of the same name... but it would be a "different" type.
You and Chris are taking the view that "the type" has a location. But,
a lot of people don't look at it this way. The things that have
locations are variables (including class data) and functions. After
all, types don't appear in object files; only variables and functions do.
Furthermore, you're taking the view that:
__attribute__((visibility ("hidden"))
on a type means something about visibility of the type in a linguistic sense, i.e., that it provides some kind of scoping, perhaps like an anonymous namespace that is different in each shared library.
But, the visibility attribute is only specified in terms of its effects
on ELF symbols, not as having C++ semantics per se. The hidden
visibility attribute says that all members of the class have hidden
visibility, unless otherwise specified.
We also allow:
struct __attribute__((visibility("hidden"))) S { __attribute__((visibility("default"))) void f(); void g(); };
which may seem equally odd: it says that you can call a function from
outside this translation unit even though you can't see the type. But,
code like this is reasonable; it says that within the defining shared
object you can call all the functions, but that elsewhere you can call
"f" but not "g". (That's orthogonal to C++ access specifiers; private
functions can have default visibility, and public ones can have hidden
visibility.)
The above class should be exactly the same as:
struct S { __attribute__((visibility("default"))) void f(); __attribute__((visibility("hidden"))) void g(); };
since there is no virtual table or other class data.
How does that serve our users?
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |