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()<
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.