同时编译此代码:
#define SET_BIT(reg,bitno) reg|=(1<<bitno)
#define CLR_BIT(reg,bitno) reg &=~(1<<bitno)
#define GET_BIT(reg,bitno) ((reg>>bitno)&1)
#define TOGGLE_BIT(reg,bitno) reg^=(1<<bitno)
switch (PIN_select){
case DIO_PIN_A:
if (level==LOW)
CLR_BIT(DIO_PIN_A,PIN_Bit);
else if(level==HIGH)
SET_BIT(DIO_PIN_A,PIN_Bit);
break;
}
我遇到以下错误:
error: lvalue required as left operand of assignment fac(0)=1;
error: lvalue required as left operand of assignmen
error: lvalue required as left operand of assignment
#define CLR_BIT(REG,BIT) REG &=~(1<<BIT)
^
note: in expansion of macro ‘CLR_BIT’
CLR_BIT(DIO_PIN_A,PIN_Bit);
^
error: lvalue required as left operand of assignment
#define SET_BIT(REG,BIT) REG|=(1<<BIT)
^
例如,此行
CLR_BIT(DIO_PIN_A,PIN_Bit);
扩展到:
DIO_PIN_A &= ~(1<<PIN_Bit);
但是,DIO_PIN_A
是整数常数(我们知道,因为在case
中使用了它,所以您不能对其进行修改。