Reputation: 15
I need to concatenate a string with an integer.I'm using this code :
#include<stdio.h>
#define SW_ENUM_VALID_COUNT(x) SW##x##_VALID_COUNT
void main()
{
int b = 16;
int SW16_VALID_COUNT=8;
printf("%d",SW_ENUM_VALID_COUNT(b));
}
What should I do in order to have the result of the expression SW_ENUM_VALID_COUNT(b) <=> SW16_VALID_COUNT
because now the result is SWb_VALID_COUNT
.
Upvotes: 1
Views: 156
Reputation: 399803
You can't do this.
The value of a variable (such as b
in your code) is not available to the preprocessor.
Upvotes: 4