Skip to main content
gamedev.net
🔒 Locked

inline

Started by RandomLogic 1 reply 250+ views
Original Post
RandomLogic
RandomLogic
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]
There aren't any stupid questions,Only stupid people.
Kylotan
Kylotan
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 ]
LilBudyWizer
LilBudyWizer
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.
Keys to success: Ability, ambition and opportunity.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.