Limit scope of #define labels

后端 未结 9 865
被撕碎了的回忆
被撕碎了的回忆 2020-12-19 05:39

What is the correct strategy to limit the scope of #define labels and avoid unwarranted token collision?

In the following configuration:

9条回答
  •  爱一瞬间的悲伤
    2020-12-19 06:08

    The correct strategy would be to not use

    #define ZERO '0'
    #define ONE  '1'
    

    at all. If you need constant values, use, in this case, a const char instead, wrapped in a namespace.

提交回复
热议问题