Angela Yan
2010-03-12 06:14:51 UTC
Hi everyone,
I got a following issue.
#define M_NUM 3
#define ABC (M_NUM * 10 * 10)
#define ABCCC_(x) #x
#define HALF_STRING(a) "Result is " ABCCC_(a)
#define RESULT_STRING HALF_STRING(ABC)
The output of the RESULT_STRING will be "Result is (3 * 10 * 10)" instead of
"Result is 300".
Anyone has any idea how to make the output to "Result is 300"??
Any help will be greatly appreciated.
ps. The value of M_NUM is generated during build time, so I can't calculated
the value of ABC first and directly insert it into the string..
Thank you very much.
Cheers,
Angela
I got a following issue.
#define M_NUM 3
#define ABC (M_NUM * 10 * 10)
#define ABCCC_(x) #x
#define HALF_STRING(a) "Result is " ABCCC_(a)
#define RESULT_STRING HALF_STRING(ABC)
The output of the RESULT_STRING will be "Result is (3 * 10 * 10)" instead of
"Result is 300".
Anyone has any idea how to make the output to "Result is 300"??
Any help will be greatly appreciated.
ps. The value of M_NUM is generated during build time, so I can't calculated
the value of ABC first and directly insert it into the string..
Thank you very much.
Cheers,
Angela