What do two adjacent pound signs mean in a C macro?

前端 未结 3 830
轻奢々
轻奢々 2020-12-14 07:38

I\'m taking a look at an application that defines a large set of constant arrays. What really confuses me is the use of two pound signs next to each other in a macro. For ex

相关标签:
3条回答
  • 2020-12-14 08:12

    ## concattenates symbols. So for example if the value of p is ab, 0x##p would become 0xab.

    0 讨论(0)
  • 2020-12-14 08:15

    ## provides a way to concatenate actual arguments during macro expansion.

    0 讨论(0)
  • 2020-12-14 08:27

    Als and sepp2k give correct answer.

    However I would like to add, that this macro seems to be completely unnecessary.

    unsigned int value = r0(b,e,a,f);
    

    can be replaced by better and shorter:

    unsigned int value = 0xbeaf;
    
    0 讨论(0)
提交回复
热议问题