Andrew wrote:
Hello,
Is it bad practice to use a function as a parameter of a macro? Will
the compiler create a full copy of the function's machine code for
each invocation of the macro? Or does it create some type of pointer
to the function? Also is there any benefit from placing a return at
the end of a function which returns void? Thanks for any advice!
Macros are not real functions in that they are completely removed before
your code even makes it to the compiler.
Calling a macro is identical to if you placed the body of the macro at
the macro call site, so no 'copy' of the function is ever made.
PS. Even passing a function as a parameter into a normal function
doesn't incur any copy overhead. Referencing a function by name simply
gives you a pointer to it, so you are essentially passing only a pointer
to the function.
--
Paul Richards
Sun Microsystems, Advanced Development
New Technology Researcher