Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Port from Win to OSX with Inline functions



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:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden

References: 
 >Port from Win to OSX with Inline functions (From: Chris Edgington <email@hidden>)
 >Re: Port from Win to OSX with Inline functions (From: John Francini <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.