Return value from a macro

Robert Osborne robert at isgtec.UUCP
Sat Feb 3 07:04:19 AEST 1990


In article <1990Jan28.040427.22679 at virtech.uucp> cpcahil at virtech.uucp (Conor P. Cahill) writes:
>A second problem is that the macros provide a slight performance gain by not
>having the function call overhead, but they increase the program size by
>duplicating code (the exact problem that functions/subroutines were designed
>to solve).  This is especially worse with complicated macros.
>
>Don't get me wrong.  I have nothing against macros and use them quite often.
>However, one should not blindly implement functions as macros.
The important thing is to know when to use macros.  Sometimes inline macros
can cut the execution time from 12 minutes to 2-3 (to use a actual example
from here).   Often the performance gain is NOT slight.  Using a macro
inside a critical loop that gets performed 500,000 times is not only "good"
it's a necessity.  Writing a macro to replace fprintf is stupid.
-- 
Robert A. Osborne   {...uunet!mnetor,...utzoo}!lsuc!isgtec!robert 



More information about the Comp.lang.c mailing list