Re: Port from Win to OSX with Inline functions
Re: Port from Win to OSX with Inline functions
- Subject: Re: Port from Win to OSX with Inline functions
- From: Eric Albert <email@hidden>
- Date: Fri, 6 Oct 2006 15:24:28 -0700
On Oct 6, 2006, at 3:09 PM, John Francini wrote: A couple of things jump to mind.
It sounds like, despite the fact that the functions are declared "inline" or are inside the class definition (you didn't say if this was straight C or C++), the compiler is deciding that the functions aren't really going to be inlined after all, and so they end up being multiply-defined.
There's a bunch of switches that control inlining. The first one to look at is -finline-limit=n, which specifies how big (in pseudo-instructions) an inline function can be. The default value is 600. Others control more intimate details. Setting -finline-limit is rarely a good idea. The compiler's idea of pseudo-instructions has very little to do with real instructions, and that in turn is very difficult to predict from your source code.
Instead, if you have a function that you're absolutely certain you want to have inlined, tag it with __attribute__((always_inline)). In general, though, the compiler does a very good job of figuring out when inlining will be a win and using it there.
Hope this helps, Eric
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden