如果我有一个匿名枚举,是否有任何方法可以将该类型的值传递给函数?例如,
typedef struct {
enum { On, Off } status;
int max_amps;
} SWITCH;
void make_switches(){
SWITCH switch1 = createSwitch( On, 15 );
SWITCH switch2 = createSwitch( Off, 20 );
}
SWITCH* createSwitch( ??? status, int max_amps ){
SWITCH* new_switch = malloc( sizeof( SWITCH ) );
new_switch->status = status;
new_switch->max_amps = max_amps;
return new_switch;
}
我想将匿名枚举的值传递给createSwitch()
函数。有什么办法吗?