I searched the forum but could not find a solution to this problem of macro contatenation with parameter. NOTE var
is not a macro
but a variable. Here is the issue:
#define HELLO (var) VALUE_ ## var
when I call say HELLO(1)
, I need the macro to be VALUE_1
instead of VALUE_var
.
Can this be done?
Hi Guys, Thank you for your replies and pointers. I looked at the post before i posted the earlier one. My problem I guess is slightly different. May be I could not explain well. Here is what I want to achieve:
#define HELLO(var) VALUE_ ## var
#define VALUE_1 // do something
#define VALUE_2 // do something
#define VALUE_3 // do something
In the code I want to use like this:
int i = 2;
HELLO(i); // should convert to a macro VALUE_2
The problem is that when I pass a variable "i" to the marco, it should convert it to a number and concatenate. The previous post used the function name as a string and concatenates with a macro VARIABLE which is not the case here.
My problem is how to get the macro use the value of i and NOT "i" itself to generate another macro as VALUE_2.
I am sure it is possible or maybe I am missing something?
Thank You.