The -fvisibility documentation talks about declarations when explaining where 
to 
put __attribute__ ((visibility("default"))). However, compiling this code:

class __attribute__ ((visibility("default"))) Foo;
class Foo {};

produces a warning:

warning: type attributes are honored only at type definition

The mentions to Windows DLLs on the documentation and the web pages it refers 
to 
are misleading: Windows compilers allows dll-exporting by putting 
__declspec(dllexport) on the declarations. Lots of dll-aware Windows and 
cross-platform code (ex. wxWindows) puts the __declspect(dllexport|dllimport) 
on 
declarations. By disallowing attributes on declarations, you difficult the use 
of the visibility feature for those libraries and break the builds on Windows 
with MinGW.

I suggest to allow (at least certain) attributes on declarations as it was the 
case for MinGW until recently or change the -fvisibility documentation for 
explicitly saying that __attribute__ ((visibility("default"))) should be used 
on 
definitions only.

-- 
           Summary: -fvisibility : misleading documentation and low QoI
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ofv at wanadoo dot es
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21675

Reply via email to