This topic is now archived and is closed to further replies.

Function Inlining in GCC

This topic is 5476 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey.. this question applies to GCC 2.95.x and GCC 3.1 (or above)... While doing some research on inlining function expansion I came across with this: "If you are using function inlining, you must: Have the inline functions implemented in the header file you include. " This is valid for MS Visual C++ 7.0, and since we''re working on a cross-platform product, I was wondering if the same rule is applied in the GCC versions I named above... The reason for this, according to MSDN documentation is: "Similarly, a project that uses function inlining yet defines the functions in a .cpp file rather than in the header file will also get error LNK2001. The header file is included everywhere deemed appropriate, but the functions are only inlined when the .cpp file passes through the compiler; therefore, the linker sees the functions as unresolved externals when used in other modules." It seems rather logical to me, but I may be wrong, any tip would be greatly appreciated. Thanks!

Share this post

Link to post
Share on other sites