我不能理解预处理器是如何工作的,在这个特定的例子中##代表什么
#include <stdio.h>
#define TEMP_KEY(type,Key) (TEMP_##type | Key)
enum TEMPKey_Type
{
TEMP_UNKNOWN = 0,
TEMP_SPECIAL ,
TEMP_UNICODE
};
enum Actual_Key
{
TEMP_RIGHT = TEMP_KEY(UNKNOWN,0x1),
TEMP_LEFT = TEMP_KEY(SPECIAL,0x1),
TEMP_UP = TEMP_KEY(UNICODE,0x1)
};
int main()
{
printf("\n Value of TEMP_RIGHT : %d ",TEMP_RIGHT);
printf("\n Value of TEMP_LEFT : %d ",TEMP_LEFT);
printf("\n Value of TEMP_UP : %d ",TEMP_UP);
return 0;
}这个#define TEMP_KEY(type,Key) (TEMP_##type | Key)是如何工作的,或者在预处理过程中TEMP_##type到底是如何替换的,又是用什么替换的?
发布于 2011-02-16 23:43:12
"##“表示拼接。因此TEMP_RIGHT = TEMP_KEY(UNKNOWN,0x1)变成了未知("TEMP_“和”TEMP_RIGHT = TEMP_UNKNOWN | 0x1,“连接在一起)
发布于 2011-02-16 23:44:08
##是#define指令中的连接运算符。
例如,TEMP_KEY的TEMP_##type (UNICODE,0x1)调用生成下一个代码:
(TEMP_UNICODE | 0x1)https://stackoverflow.com/questions/5018465
复制相似问题