uma676 said:
Hi all,
I want to know the differebces between function and macro in c
language. if anybody can tell me atleast 4 diff's. for which i will
be regrated.
Rgds,
Balaji
The main difference you want to know about macros vs functions is:
When you call a function your compiler enters a call-sequence (which takes
time) and allocates a new stack frame for that function (whcih takes text
stack space) so that the function's body can be executed. After it's done
you enter a returning-sequence phase (which takes time).
A macro does not need anything of the above, because it's preprocessor's job
to expand a macro, it's only about text replacement, not about compiler
stuff or code-generating issues. So you don't expend time and space doing
what a function would need in order to be executed.
That makes functions and macros completely different even if the result of
using both is, in some cases, the same. One must know it's suitable to use
one or the other. For instance: you can't point a pointer to a macro, but
you can use pointers to functions...
_______
Dienekes