我無法理解如何預處理器可行,什麼不可行的##
代表在這個特殊的例子預處理#定義
#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 15:44:16
行了謝謝 – Totie 2011-02-16 15:49:35