How to resolve int variable before passing to C/C++ Macros? [closed]
I am trying to execute the following code: #define channel1 10 #define channel(id) channel##id int main(){ int id = 1; cout << channel(id)<<"\n"; return 0; } I get the following error: error: use of undeclared identifier 'channelid' Instead, I want an output to be 10 , as channel(id) should be preprocessed to channel1 and which replaces the value with 10. Is there any way to achieve it? The problem is caused because you're trying to mix information that it is considered at different stages in the processing of the code. Macros and all CPP (C-Pre-Processor) stuff happens (as its own name