shahrahulb
asked on
macro
i have a macro to compute max of 2 numbers
#define max2( x, y ) (x) > (y) ? (x) : (y)
similarly i can define function to same stuff
int max(int x, int y) {
x > y ? return(x) : return(y);
what is the advantage of using macro over function
#define max2( x, y ) (x) > (y) ? (x) : (y)
similarly i can define function to same stuff
int max(int x, int y) {
x > y ? return(x) : return(y);
what is the advantage of using macro over function
ASKER
by function call overhead, do u mean to say, storing variables in stack, save memory location etc.....
if that is the case, how macros work
if that is the case, how macros work
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
what difference does it make if the c0de size increases
>> what difference does it make if the c0de size increases
on usual pc's it makes no difference, since memory-size is not a matter for those boxes in these days.
but imagine you develop software for pda's or mobiles or some other *mini*-computers, then it makes a
difference.
ike
on usual pc's it makes no difference, since memory-size is not a matter for those boxes in these days.
but imagine you develop software for pda's or mobiles or some other *mini*-computers, then it makes a
difference.
ike
function wll work with max(++x,++y)