Preprocessor counter macro

后端 未结 1 1298
半阙折子戏
半阙折子戏 2021-01-12 20:13

Is there a way to create a COUNTER() macro (which follows the C++11/14 standard) that is expanded to a number which increases by one every time COUNTER()<

相关标签:
1条回答
  • 2021-01-12 20:50

    GCC, and (I believe) VC++ both provide the __COUNTER__ macro, which does about what you'd expect. I don't know that it follows the standard exactly, but it's probably close enough for real-world use.

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