mercredi 25 février 2015

Macro-based counter

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.

I have tried Boost.Preprocessor, but I am not good at it.


Aucun commentaire:

Enregistrer un commentaire