Reading Zend Engine API code: What does ## (double hash) mean?

前端 未结 3 1469
抹茶落季
抹茶落季 2020-12-15 06:02

Out of curiousity, I\'m reading the Zend Engine API code and encountered quite a number of ## in their #define\'s. For example, at /usr/lib/php5/Zend/zend_API.h:

<         


        
相关标签:
3条回答
  • 2020-12-15 06:16

    The ## concatenates what's before the ## with what's after it. So in your example doing ZEND_FN(foo) would result in zif_foo

    0 讨论(0)
  • 2020-12-15 06:30

    Echo RvV's answer.

    Be aware that when concatenating literal strings you may find some inconsistencies between pre-processors/compilers. Some will require the ##

    #define STR_CAT(s1, s2)   s1 ## s2
    

    as in

    const char s[] = STR_CAT("concat", "enation")
    

    whereas other will baulk at it, and instead just require that the two literals will be joined by the compiler (as opposed to the pre-processor), so will require

    #define STR_CAT(s1, s2)   s1 s2
    

    HTH

    0 讨论(0)
  • 2020-12-15 06:35

    http://www.cppreference.com/wiki/preprocessor/sharp

    0 讨论(0)
提交回复
热议问题