I have to write some constants in different files with some integer id. For example:
#define MESSAGE_FIRST 0
In other file:
#define MESSAGE_ANOTHER 1
Any ways to get that id automatically in compile time? Something like:
#define MESSAGE_AUTO GetNextId()
I can’t use enums here because this directives will be in different files.
Thanks.
p.s. GCC, Linux
You can do a compile-time counter, with inheritance and function overloading:
You can see it in action here. Also works with msvc.