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

前端 未结 16 1540
有刺的猬
有刺的猬 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:41

    I've never used it for anything but a DEBUG macro. It's convenient to be able to say

    #define WAYPOINT \
        do { if(dbg) printf("At marker: %d\n", __COUNTER__); } while(0);
    

提交回复
热议问题