News for hackers. Stuff that matters.
Re:Some obscure C features by mrgriffin on Friday January 26, 2018 @03:38AM (#16237776)
That'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!

There are no comments on this comment yet.