Does it support application-wide counter?
I think, the counter starts from the first value at the beginning of each new translation unit, is it possible to use an incrementing counter application-wide? I want to have unique values between translation units either. Do you think FILE macro (converted to an int value, in compile-time) helps?
Can you give me some context? Constant evaluation is always translation unit focused. If you want to make each translation unit fully independent I recommend adding an anonymous namespace in the unconstexpr headers or in your project. This will make sure that each declaration / function / etc.. is only usable inside the translation unit and will not leak its state to other ones.
To access a global array by index from different TUs, I need to have a unique number even between TUs. I want to keep hit count for specified statements like the following;
A.cpp globArr[0]++; globArr[1]++; globArr[2]++; globArr[3]++;
B.cpp globArr[4]++; globArr[5]++; globArr[6]++;
Global.h int globArr[7];
The workaround is having distinct arrays for each TUs, is there another way?