http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56527
Bug #: 56527 Summary: Provide an import counterpart to attribute((visibility("protected"))) Classification: Unclassified Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: l...@mit.edu This is a common idiom: #ifdef BUILDING_LIBWHATEVER #define LIBWHATEVER_API __attribute__((visibility("protected"))) #else #define LIBWHATEVER_API ??? #endif Protected can be replaced with default without changing anything. The issue is: what to specify for imports (the ??? above). The common approach seems to be __attribute__((visibility("default"))), since hidden is asking for trouble and protected won't link due to undefined protected symbols. Neither one is good. I want an attribute (which could be a new visibility) that acts like default visibility for undefined symbols, like default visibility [1] for inline defined symbols, and fails to compile for non-inline symbols. (In this definition, "inline" should probably include implicitly instantiated templates as well.) This will catch errors when a non-inline function is defined in the right place. [1] This isn't quite ideal. To avoid interposing a possible protected instantiation of an inline function, these should probably end up as default visibility but weak. P.S. It would be neat if calls to functions with this attribute generated explicit GOT references rather than going to the PLT. (IMO Windows gets this right.)