Archived

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

Andrew Russell

Inline Keyword

Recommended Posts

Quick question, What does the inline keyword do, exactly? My compiler dosn''t explain it very well in the documentation. I am just wondering if I am using it correctly. Thanks. ANDREW RUSSELL STUDIOS

Share this post


Link to post
Share on other sites
It basically tries to insert the "inline"''d function into the position of the code from where it was called. This basically works somewhat like a macro... In all, this speeds up the code by removing a function call completely (though, it may slow it back down later during the funciton, depending on what you are doing in the inlined function).

I tnd to inline all of the short functions that just do trivial things.

-Chris Bennett of Dwarfsoft - The future of RPGs Thanks to all the goblins in the GDCorner niche

Share this post


Link to post
Share on other sites
if I''m not mistaken, the inline keyword just gives hints to the compiler that you want the function inlined. Thus, it is up ot the compiler whether it wants to inline the function or not.

In MSVC to force the compiler to inline code, use __inline. Don''t know if this is portable to other compiler....

Share this post


Link to post
Share on other sites
u can also inline using the compiler directive
#pragma auto_inline(on) to inline all your functions which can be inlined

{ Stating the obvious never helped any situation !! }

Share this post


Link to post
Share on other sites