4 ms·
Note that this does not work if you make use of __COUNTER__ anywhere else in the file (directly or indirectly).
by cperciva 9y ago
Note that this does not work if you make use of __COUNTER__ anywhere else in the file (directly or indirectly).
- mrgriffin 9y agoThat's true, and in the event that you're actually using __COUNTER__ for something you could build something similar out of #include with a header that increments an internal number. // COUNTER.h #if !defined(COUNTER) #define COUNTER 0 #elif COUNTER == 0 #undef COUNTER #define COUNTER 1 #elif COUNTER == 1 #undef COUNTER #define COUNTER 2 ... #end if And then change each invocation of ELEMENT to have a leading #include "COUNTER". #include "COUNTER.h" ELEMENT(x) #include "COUNTER.h" ELEMENT(y) Note that if you take this approach then (as far as I know) you're actually writing standard C!