Hello,

Paulo Matos wrote:

> Can g++ optimize an (almost) empty function such as
> ostream& foo(ostream& o) { return o; }

When inlining, surely.

You might include some simple inline definition of the function in its
header file depending on the DEBUG macro.

// debug.h

void foo();
#ifndef DEBUG
inline ostream& foo(ostream& o) { return o; }
#endif

//debug.cc

#ifdef DEBUG
ostream& foo(ostream& o)
{

....

}
#endif

> Problem is I'm strugling to find a way to insert debugging info
> without messing around with Macros too much.


Sometimes it might be helpful to have the logging functions available
even in release mode, just the calls should be neutralized. Then you
could define an simple inline function in release mode, and an inline
function calling the actual code under another name.

There are libraries around to help with logging, maybe you could use one
of them for the dirty work.

Bernd Strieder

_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to