View Single Post
Old 05-01-2003, 04:23 AM   #2
Tamsyn@zebedee.org
New Member
 
Join Date: Mar 2003
Posts: 23
Tamsyn@zebedee.org is on a distinguished road
I expect it's because the code® historically was in C, that doesn't support inline functions.

C++ has const to replace #define symbols (as opposed to 'functions' if you can call them that) and inline otherwise. The most obvious advantage is type safety.

One advantage of macros is that they can be conditionally compiled out of your exe - for example debugging code can be compiled out when building a 'release' exe.

Another is they support which (I think) is not the case with an inline function - it would report the number of the line where the inline function is defined, not where it is called from.

Another is that they can be used as shorthand for declaring a local variable. For example

#define FUNCTION_START(name) FunctionLogger(name);

which declares a local object of type FunctionLogger, initialised with the function name. This object could log to a file that the function has been entered, and its destructor can log to the file that its exiting. You can't do that with an inline function.
Tamsyn@zebedee.org is offline   Reply With Quote