GCC ignores function attributes

Nikos Chantziaras realnc@gmail.com
Thu Jun 12 00:43:00 GMT 2014


According to the documentation:

https://gcc.gnu.org/onlinedocs/gcc-4.8.2/gcc/Function-Attributes.html#Function-Attributes

and more specific, the example about the visibility attribute:

   void __attribute__ ((visibility ("protected")))
   f () { /* Do something. */; }

doesn't work for me. I have this C++ function prototype:

   const SDL_AudioSpec& __attribute__((visibility("default")))
   spec();

Compiling this with g++ 4.8.2 gives me:

   warning: 'visibility' attribute ignored on non-class types

I do not understand :-/  I found this bug on GCC's bugzilla:

   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30361

but it is very old and unconfirmed.

In any event, I have no idea what I am doing wrong here.



More information about the Gcc-help mailing list