As mentioned in the previous article # connector, this time I finally found an article that can explain the problem well:
From http://blog.csdn.net/killer_wy1985/archive/2010/04/07/5458576.aspx
Link character in C Language
(1) # connector and # Operator in macro definition
# The Concatenation symbol is composed of two pound signs. Its function is to connect two substrings (tokens) in the macro definition with parameters to form a new substring. But it cannot be the first or last substring. The so-called token refers to the minimum syntax unit that the compiler can recognize. The specific definition has a detailed explanation in the compilation principle, but it does not matter if you do not know. At the same time, it is worth noting that the # operator replaces the passed parameters as strings. Let's take a look at how they work. This is an example on msdn.
HypothesisProgramHas defined such a macro with parameters:
# Define Paster (n) printf ("token" # N "= % d", Token # N)
At the same time, an integer variable is defined:
Int token9 = 9;
Call this macro in the following way in the main program:
Paster (9 );
During compilation, the above sentence is extended:
Printf ("token" "9" "= % d", token9 );
Note that in this example, the "9" in Paster (9); is regarded as a string and connected with the "token", thus becoming the token9. # N is also replaced by "9.
As you can imagine, the result of running the program above is to print token9 = 9 on the screen.
(2) "/" and a macro with a long number of rows
The macro definition can contain more than two lines of commands. In this case, you must add "/" on the rightmost side and the line "/". No more characters are allowed, and no comments are allowed, the following line must end with "/", "/" followed by a space, and an error will be reported, not to mention it.
# Define Exchange (a, B ){/
Int t ;/
T = ;/
A = B ;/
B = T ;/
}