To put it simply,#连接字符串, # #连接两个参数
There are several steps involved in extending the # define definition symbols and macros in your program.
1. When calling a macro, first check the parameters to see if any symbols defined by # define are included. If they are, they are first replaced.
2. The replacement text is then inserted into the location of the original text in the program. For macro, the parameter names are replaced by their values.
3. Finally, scan the result file again to see if it contains any symbols defined by # define. If so, repeat the above process.
Macro and # define definitions can contain symbols for other # define definitions. However, a macro cannot have recursion.
# # The connection symbol is made up of two #, and its function is to join the 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 substring (token) refers to the smallest syntax unit that the compiler can recognize.
It can be spliced with symbols (token-pasting operator).
There is an example on MSDN:
#define PASTER (N) printf ("token" #n "=%d\n", token# #n)
int token9 = 100;
Call Paster (9) Again, and token# #n直接合并变成了token9 after the macro expands. The entire statement becomes a
printf ("token" "9" "=%d", token9);
In the C language, two concatenated double quotes in the string are automatically ignored, and the above sentence is equivalent to
printf ("Token9 =%d", token9);.
i.e. Output TOKEN9 = 100
"Essay" #与 # #的使用含义与区别