> Sadly, you can't set the value of an index in an array like that in the top level in C, only inside functions.
This is not exactly true. An assignment is a value, you can do e.g.
int a = b[x] = 0;
(which implies that you can do your array-index assignments at the global level by creating nonsensical/unused variables and initializing them).
__attribute__((constructor))
https://github.com/kbob/schetoo/blob/master/prim.h#L215
This also works across multiple source files, unlike __COUNTER__.
The biggest downside is that (as far as I know) it's impossible to get this approach to coordinate across translation units, so you're forced to define a main in each test file (via the library's header file?). But I doubt that matters too much in practice.