Macro as an argument to a macro in C -
I want to know which macro gets replaced first in the following code
#define A 100 #define B 200 #define C (A, B) A + B When we use C, the evaluation will be left to right or right to the left First gets the value or A gets the first value
I have given this example, just to simplify things, I can be wrong, I can be wrong. The real thing I want to ask is, if A and B also take the argument and have the scope of expansion, then the first thing
I'm not sure what you say. There is no point where you can see half the results of a preprocessor; The entire input file is preprocessed, then handed over to the compiler.
I think the name for the macro logic will never be changed as if they were stand-alone symbols.
I tried to do this, and this program:
#include & lt; Stdio.h & gt; #define a 100 #define b 200 #define c (a, b) a + b integer main (zero) {printf ("a =% d \ nb =% d \ nc (1,2) =% d \ n" , A, B, C (1,2)); Return 0; } print
a = 100b = 200c (1,2) = 3 Therefore, The expansion of C (1,2) defines 1 + 2 , A and B does not make any difference. Of course I have to say that I have found the above very bad behavior , because it is quite confusing. Do not use all caps names for macro logics, because macros and preprocessor symbols use such names.
Comments
Post a Comment