c++.dos.32-bits - Re: Optimization of inline functions
Hi,Walter! I have some questions concerning optimization of inline functions: 1) If inline function accepts some params and does nothing (e.g. inline void _DebugPrintf(const char *fmt, ...) {}), will the code that calls this function fully eliminated? 2) And what happens if the results of some functions are passed as params to the function mentioned above? It is desirable for me, that compiler fully eliminate this call and don't call functions to make parameters which will never be used. I use the constructions mentioned above to implement easily turned off debugging code (if in debug mode, _DebugPrintf is out-of-line function, and in no-debug mode _DebugPrintf is inline function that does nothing). Basically, the parameters passed for this function are for debug only, and in the case : _DebugPrintf ( "%d", some_dbg_func()); /*non-debug mode*/ no code should be generated (some_dbg_func should not be called). Looking forward for your reply, Nic Tiger.
Mar 11 2002
"Nic Tiger" <nictiger pt.comcor.ru> wrote in message news:a6hssj$13jc$2 digitaldaemon.com...1) If inline function accepts some params and does nothing (e.g. inline void _DebugPrintf(const char *fmt, ...) {}), will the code that calls this function fully eliminated?Yes.2) And what happens if the results of some functions are passed as params to the function mentioned above?Those functions still get called and any side effects of the argument evaluation get performed.It is desirable for me, that compiler fully eliminate this call and don't call functions to make parameters which will never be used.You'll need to use the macro preprocessor then. Of course, D has a much better solution <g>.
Mar 11 2002