Consider the following code:
1. #define SUFFIX 5-5
2. #define XFUNC_0( x ) (100 * x)
3. #define XFUNC_1( x ) (101 * x)
4. #define XFUNC_2( x ) (102 * x)
5. #define CATX( x, y ) x##y
6. #define CAT( x, y ) CATX( x, y )
7. #define XFUNC CAT( XFUNC_, SUFFIX )
8. #if XFUNC(2) == 200
...... etc
N. #endif
This code does not seem very useful, this is because it is just a part of my real code, simplified. The question is: - how can I convince the preprocessor to perform first 5-5 (just an example of a math operation) and the result (in this example, zero) to be concatenated to XFUNC_? As it is now it does not work, it tells me "unexpected tokens following preprocessor directive - expected a newline", at line 8. update: It seems right, the above code will be simple code replacement with the result XFUNC_5-5. But in this case I have another question: - does exist a way to have a function like macro or something which accepts as input(parameter) an expresssion and outputs a number; I think maybe something like a vector where you put consecutive numbers: you put the index (which could be an entire expresion) and you get as result the same, except that now is not expression but "pure" number which could be then concatenated