Search notes:

Predefined preprocessor macro __COUNTER__

__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.

variables.h

int a = __COUNTER__;
int b = __COUNTER__;
int c = __COUNTER__;
Github repository about-cpp, path: /preprocessor/macros/predefined/__COUNTER__/variables.h

main.c

#include "variables.h"
#include <stdio.h>

int main() {
  printf("__COUNTER__=%d\n", __COUNTER__);
  printf("a=%d, b=%d, c=%d\n", a, b, c);
}
Github repository about-cpp, path: /preprocessor/macros/predefined/__COUNTER__/main.c

See also

Preprocessor: macros

Index