Has anyone ever had a use for the __COUNTER__ pre-processor macro?

前端 未结 16 1534
有刺的猬
有刺的猬 2020-11-29 00:37

The __COUNTER__ symbol is provided by VC++ and GCC, and gives an increasing non-negative integral value each time it is used.

I\'m interested to learn w

16条回答
  •  一向
    一向 (楼主)
    2020-11-29 00:46

    I've used it in a compile-time assertion macro to have the macro create a name for a typedef that will be unique. See

    • Ways to ASSERT expressions at build time in C

    if you want the gory details.

提交回复
热议问题