This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Statement incorrect in doc
- From: Rob Aberg <roa at charter dot net>
- To: gcc at gnu dot org
- Date: Sun, 27 Oct 2002 13:28:15 -0500
- Subject: Statement incorrect in doc
While looking in Google for discussions on stategies for optionally
inlining C functions in a semi-portable way, I ran across your online
doc:
http://gcc.gnu.org/onlinedocs/gcc/Inline.html
The section heading is "An Inline Function is As Fast As a Macro".
That's not entirely true. Often, an inline function is faster: if a
macro uses its "input arg" more than once and the arg is an expression,
the arg-expression is evaluated multiple times unless other
optimizations in gcc are active and see the common subexpression and
eliminate it. Consider this macro:
#define my_min(X,Y) ( ((X) < (Y)) ? (X) : (Y) )
It will evaluate either the (X) or the (Y) expression twice. It can be
arbitrarily worse for nested macros. Or am I just missing something?
Now that I am reminded, I'll order this one as well -- I have the gdb
book, it is very well written...
Thanks,
Rob Aberg
Grafton, MA