#, ##&# @ In define #,##&&#@

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.