I have some legacy code that contains this typedef:
typedef enum simple_op_enum {
#define SOP(OPCODE, NAME, FORM, SUIFOP) OPCODE ,
#include "simple_ops.def"
LAST_OP
} simple_op;
The #include file contains several lines of the form:
/* no operand instructions */
SOP( NOP_OP, "nop ", BASE_FORM, io_nop)
The token "simple_op" occurs later in a struct:
typedef struct simple_instr_struct {
simple_op opcode; /* the opcode */
There are several things I don't understand:
What is accomplished by having a comma at the end of the #define statement? I thought that was illegal.
What is being accomplished by the enum, especially LAST_OP
How do I access the value of opcode in a simple_instr_struct?