• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Inline symbols visibility
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inline symbols visibility


  • Subject: Re: Inline symbols visibility
  • From: Guillaume Billard <email@hidden>
  • Date: Thu, 1 Apr 2010 15:11:30 +0200

Le 1 avr. 2010 à 12:11, Jean-Daniel Dupas a écrit :


Le 1 avr. 2010 à 11:58, Guillaume Billard a écrit :

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:
http://lists.apple.com/archives/xcode-users/2005/Jul/msg00609.html.

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!



Does GCC option '-fno-default-inline' is helpful in your case ? 

-fno-default-inline
Do not assume `inline' for functions defined inside a class scope. See Options That Control Optimization. Note that these functions will have linkage like inline functions; they just won't be inlined by default. 


I put the flag in "Other C++ Flags" and the link error is still there. I reckon this part explains it: "these functions will have linkage like inline functions".

But anyway reading the "Options Controlling C++ Dialect" you quoted above and the part from "Options That Control Optimization" below, I'm not sure what the described behavior is:

-fno-default-inline
Do not make member functions inline by default merely because they are defined inside the class scope (C++ only). Otherwise, when you specify -O, member functions defined inside class scope are compiled inline by default; i.e., you don't need to add `inline' in front of the member function name.

Does that mean that a method defined inside a class scope would need the inline keyboard to be inlined? That would be a big change that may not be desirable.

Guillaume

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Inline symbols visibility (From: Guillaume Billard <email@hidden>)
 >Re: Inline symbols visibility (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: Puzzling Analyzer output
  • Next by Date: Re: Puzzling Analyzer output
  • Previous by thread: Re: Inline symbols visibility
  • Next by thread: Re: Inline symbols visibility
  • Index(es):
    • Date
    • Thread