Archived

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

RandomLogic

inline

Recommended Posts

The following line appears in MSDN library on the inline __inline and __forceinline page: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_inline_specifier.asp "The function is virtual and is called virtually. Direct calls to virtual functions can be inlined" It reffers to when a function DOES NOT expand inline. My question is what do they mean by direct call to a virtual function? and is there something to do when I have a virtual function that would be called a lot and that each inheritor of that class must implement independantly. Almost forgot, can static functions be inline? for some reason the compiler didn't let me link them. [edited by - RandomLogic on December 25, 2002 8:36:40 AM]

Share this post


Link to post
Share on other sites
Sometimes a virtual function is called when the compiler knows the type of the object at run time. Therefore, it''s not necessary to perform the run-time type check and in turn, that means the compiler knows exactly which code to put inline.

Static functions are just like normal functions, and can certainly be inline.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

Share this post


Link to post
Share on other sites
I would assume "T MyT; MyT.VFunc();" as opposed to "T *MyT; MyT->VFunc();". As far as I know the first is a direct call, the second is an indirect call. The definition of T tells you which the function the first one is calling. The history assignments to MyT tells you which one the second is calling. Making matters even worse MyT could be pointing at an instance of a class derived from T in another compilation unit for which this compilation unit has no definition.

Share this post


Link to post
Share on other sites