http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53611
Bug #: 53611 Summary: class with hidden visibility cause function returns pointer to class also be hidden Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: kirbyz...@sogou-inc.com [root@djt-17-109-v06 tmp]# cat tvisi.cpp extern "C" typedef struct __cook cook_t; extern "C" cook_t* myopen(); struct __attribute__ ((visibility ("hidden"))) __cook { virtual ~__cook() = 0; }; //__attribute__ ((visibility ("default"))) cook_t* myopen() { return 0; } [root@djt-17-109-v06 tmp]# g++ tvisi.cpp -o libxx.so -shared -fPIC && nm -D libxx.so | fgrep myopen 00000000000005cc T myopen The function myopen is exported by g++ 4.4.6 [root@djt-17-109-v06 tmp]# g++47 tvisi.cpp -o libxx.so -shared -fPIC && nm -D libxx.so | fgrep myopen [root@djt-17-109-v06 tmp]# The function myopen is not exported by g++ 4.7.0 Workaround: define '__cook' after the definition of 'myopen'