Is it possible to create compile time constants like this:
// event.h
#define REGISTER_EVENT_TYPE() ... // Returns last_returned_number+1
// header1
#define SOME_EVENT REGISTER_EVENT_TYPE()
// header2
#define SOME_OTHER_EVENT REGISTER_EVENT_TYPE()
Where SOME_EVENT
will be 0 and SOME_OTHER_EVENT
will be 1.
Tried the following code:
#define DEF_X(x) const int x = BOOST_PP_COUNTER;
#define REGISTER_EVENT_TYPE(x) BOOST_PP_UPDATE_COUNTER()DEF_X(x)
#include REGISTER_EVENT_TYPE(SOME_EVENT_TYPE)
But include eats constant declaration.