__COUNTER__
is a non-standard compiler extension for the GNU compiler. Apparently, it's also implemented in Microsoft's compiler and the clang compiler. __COUNTER__
evaluates to an integer literal whose value is increased by one every time it is found in a source code text. int a = __COUNTER__; int b = __COUNTER__; int c = __COUNTER__;
#include "variables.h" #include <stdio.h> int main() { printf("__COUNTER__=%d\n", __COUNTER__); printf("a=%d, b=%d, c=%d\n", a, b, c); }