Some time ago, when reading the code of wince, it was used in the macro definition ##, as shown below:
# Define Gpeblt_funcname (basename) (scode (GPE: *) (struct gpebltparms *) & GPE :## basename
In # define, only the # And # operations are defined. # Used to convert parameters into strings. # used to connect two parameters before and after, and convert them into a string.
1 # Define Tostring (a) #
2 Tostring (a B CD ); // A B CD
3 Tostring (A \ n B CD ); // A
4 // B CD
5 Tostring (A \ n B CD ); // A n B CD
6
7
8 # Define Concat (x, y) x # Y
9 Concat ( " ABC " , " Def " );
10 Concat ( 123 , 4 );
11 Concat ( 123.0 , 5 );
12 // ======================================
13 // CAT (123.0, 5.5 );
14 // CAT ('A', 'B ');
15 // CAT ("ABC", 'D ');
16 // CAT ('A', 1234 );
17 // CAT ("ABC", 1234 );
18 // ===== Above can't compile ======
19
20
In addition, there is another method found on the Internet: # @, convert the parameter to a character
1 # Define Tochar (a) # @
2 Tochar (); // A
3 Tochar (AB ); // B
4 Tochar (ABC ); // C
5 Tochar (ABCD ); // D
6 // Tochar (ABCDE ); // Too character characters in constant
7 Tochar ( 1 .); // .
This is not seen in standards. The above tests are performed in the vs studio environment. I don't know if GCC has the same usage.