我有一個包含此類型定義了一些舊代碼:Ç#define語句,枚舉,結構
typedef enum simple_op_enum {
#define SOP(OPCODE, NAME, FORM, SUIFOP) OPCODE ,
#include "simple_ops.def"
LAST_OP
} simple_op;
中的#include文件包含格式的幾行:
/* no operand instructions */
SOP(NOP_OP, "nop ", BASE_FORM, io_nop)
令牌「simple_op 「在結構發生以後:
typedef struct simple_instr_struct {
simple_op opcode; /* the opcode */
有幾件事情我不明白:
什麼是通過在#define語句末尾加逗號來實現的?我認爲這是非法的。
什麼正被枚舉完成,尤其是LAST_OP
如何訪問一個simple_instr_struct操作碼的值?
http://stackoverflow.com/questions/264269/what-is-一個好的參考文檔化圖案-的使用-的-X-宏-在-C-或-possib –