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]

Re: Visibility and C++ Classes/Templates


Geoffrey Keating wrote:

[#pragma visibility affecting explicit instantiations]

A consequence of this is that if a user instantiates a template that they don't 'own' (that is, a template from a different module), they must make sure that no #pragma is in effect, because the other module may have a specific idea about what visibility should be used.

Can you give an example? You can also get different visibility implicitly, if a template argument has more restricted visibility than the template; the instantiation gets the more restricted one.


I'm not sure how exactly they can do this.  Is there a visibility
pragma for "no setting"?

#pragma GCC visibility pop


It seems like this would be a common enough mistake that there should
be a way to get a warning about it.

I think it would be intentional more often than it would be a mistake.


In the traditional declaration/definition model, if you try to change
the linkage of something you get an error...

Yes. If you try to change the visibility of something you also get an error. But an instantiation need not have the same visibility as its template.


For instance, code coming from VC++ will tend to default to hidden visibility, but make the interfaces default visibility. If a particular instantiation of a template is part of the interface of a non-template class, it must also get default visibility.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]