Hello,
We're using GCC 4 visibility feature, by compiling our app with -fvisibility=hidden and adding __attribute__((visibility("default"))) as a macro for symbols that need to be exported. After reading Apple's guide and the GNU wiki about visibility, I thought that making a class visible made everything inside it visible as well. But when compiling one of our libs with -O3, a method is not exported even though the class it belongs to uses the right attribute. This method is defined inside the class definition, so I'm guessing that the compiler inlined it and that's why it wasn't exported.
I found this thread where it seems that the same behavior occurred:
Adding the "default" visibility attribute to the inline method solved the problem. If I'm not mistaken, the compiler gets to decide wether to inline methods or not, even when they're defined out of their class definition. It appears that it can inline methods for classes that use __attribute__((visibility("default"))), but I don't know if it can do the same for out-of-class methods. I'm hoping not. I'd like to know if adding the attribute to a method of a visible class whenever it doesn't get exported is the right approach. It kind of turns the granularity of the visibility from class to method. The only other solution that I can think of is to define the method out of the class but as I said I don't know if it's supposed to work all the time, and in my case it's not a practical thing to do.
Thanks!
Guillaume
|