how can I make this example code work?(In C or C++)
The cout is just for example.I want evaluate the correct decremented number
#define PRINT_1 std::cout<<"One : " <<1;
#define PRINT_2 std::cout<<"Two : " <<2;
#define DEC_AND_PRINT(number) PRINT_##number-1
When I call DEC_AND_PRINT(3)
, I expect this:
DEC_AND_PRINT(3) PRINT_##(3-1) -> PRINT_2 -> std::cout<<"Two : "<<2
But the compiler give-me an error :
GCC : error: 'PRINT_3' was not declared in this scope...
GCC : note: in expansion of macro 'DEC_AND_PRINT' DEC_AND_PRINT(3)
How I can decrement the argument?
Basically, I'm trying to make a macro function get a number and call another macro function in syntax _name_of_macro_decremented_number.