How to token paste a number?

145 Views Asked by At

I have to create objects dynamically. So for that I have the following:

#define timerID(num) timerID_##num

This results in as timerID_num instead of say timerID_1. Can someone let me know how to do this?

1

There are 1 best solutions below

3
On

Check following code snippet:

#define f(g,g2) g##g2

void main()
{
   int timerID_1 = 12;
   printf("%d",f(timerID_,1)); 
}

This will concatenate to timerID_1. I printed the value just for debug.