Suppose I have a list of #define
s in a header file for an external library. These #define
s represent error codes returned from functions. I want to wri
take a look at boost preprocessor. You could create list/array/sequence of code pairs:
#define codes ((1,"code1"))((...))
#define code1 1
...
// then use preprocessor FOR_EACH to generate error handlers
relevant link:
http://www.boost.org/doc/libs/1_41_0/libs/preprocessor/doc/ref/seq_for_each.html
http://www.boost.org/doc/libs/1_41_0/libs/preprocessor/doc/ref/tuple_elem.html