
- Forum
- Programming Talk
- C and C++
- Evaluation of Preprocessor Directive
Evaluation of Preprocessor Directive
This is a discussion on Evaluation of Preprocessor Directive within the C and C++ forums, part of the Programming Talk category; If I have #define defined as #define dividefunc(a,b) a/b and have a function call as dividefun(x+2,y+3); Suppose x=13 and y=2 ...
-
Evaluation of Preprocessor Directive
If I have #define defined as
#define dividefunc(a,b) a/b
and have a function call as
dividefun(x+2,y+3);
Suppose x=13 and y=2
How will the #define gets evaluated
Will it get substituted as
dividefun(13+2,2+2) which is equal to
dividefun(15,4)
and then get divided as 15/4 =4
or
will it get evaluated as
dividefun(x+2,y+2)
x+2/y+2 which is equal to
13+3/2+2 which becomes 13+1+2=16
Kindly let me know how the evaluation takes place
-
It will get evaluated as
dividefun(x+2,y+2)
x+2/y+2 which is equal to
13+3/2+2 which becomes 13+1+2=16
This is because whenever a Preprocessor Directive is called the values given in parameters are substituted as such in the calling directive and then only operation takes place.

Reply With Quote





