In article <11**********************@b28g2000cwb.googlegroups .com>,
<di**********@yahoo.comwrote:
>HI.In what circumstances we should use a macro and when we should use a
function?
macro: if you need the result at compile time, or if you
need to "stringize" something, or if you need to splice
together parts of a name to arrive at a new preprocessor macro name
whose value is required, or if you need to construct new syntaxes
or if you need a form that needs to work over multiple types
>If we use macro then will the size of the executable
increase?
That's an implementation issue, and might depend on the precise
nature of the macro and upon the contexts it is used in or upon
the number of times it is used. Sometimes using macros might result
in smaller executables and sometimes it might result in larger executables.
Talking about the size of an executable is usually not particularily
useful. An executable might include debugging information, might
include library linkage information, might bother to "merge"
constant literals, might "unroll" loops for optimization, might
use a longer sequence of instructions rather than a shorter sequence
if the longer sequence would be more efficient, might contain
the same code compiled for multiple architectures, and so on.
--
I was very young in those days, but I was also rather dim.
-- Christopher Priest