On (11 Sep 97) Roger Scudder wrote to Jerry Coffin...
JC> if an inline function will work, it's better than a macro. It
JC> will generally eliminate the same function call overhead that a
JC> macro is usually intended to eliminate.
RS> But inline is only a request. The compiler does not have to
RS> place the code inline.
That's why I said will _generally_ eliminate the overhead. It doesn't
always, though it's been my experience that compilers (at least the ones
I've used) are pretty good at determining when a function is doing
enough that the call/return overhead is too small to worry about.
RS> Would the same apply to a macro? In other words... even though
RS> the preprocessor expands the code inline the compiler could treat
RS> it as if it were a function call?
Yes, though in honesty this is far less common. Typical examples would
be C interpreters and P-code compilers. I don't know of any compilers
that actually directly find common sections of code and put them into
functions. However, for a lot of purposes, that'd probably be more
useful than inlining control. (Then again, it's also a lot more
difficult to do...)
Later,
Jerry.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)
|