I want to create a recursive Macro the will create the “next” class.
Example:
#define PRINTME(indexNum) class m_##(indexNum+1) { }
The indexNum + 1 is evaluated as an int, and won’t concatenate to the class name.
How can I cause the compiler to evaluate that, before concatenating?
The simple answer is that you can’t. The preprocessor generally deals in text and tokens; the only place arithmetic is carried out in in
#ifand#elifdirectives.Also, macro expansion isn’t recursive. During expansion, the macro being expanded is disabled, and is not available for further substitution.