|=在C中做什么?

|=在C中做什么?,c,operator-keyword,C,Operator Keyword,我试图理解C运算符|=的作用: // Initialize the green led // Enable the clock for PORT D. See Page 216 of the Datasheet SIM_SCGC5 |= (1U<<12); // Enable the mux as GPIO. See Page 193 of the Datasheet PORTD_PCR5 = 0x100; //初始化绿色指示灯 //启用端口D的时钟。参见数据表第216页 S

我试图理解C运算符
|=
的作用:

// Initialize the green led
// Enable the clock for PORT D.  See Page 216 of the Datasheet
SIM_SCGC5 |= (1U<<12);

// Enable the mux as GPIO.  See Page 193 of the Datasheet
PORTD_PCR5 = 0x100;
//初始化绿色指示灯
//启用端口D的时钟。参见数据表第216页
SIM_SCGC5 |=(1U它是一个或复合赋值,它与:

SIM_SCGC5 = SIM_SCGC5 | (1U<<12);

SIM_SCGC5=SIM_SCGC5|(1U
a |=b;
a=a | b;
就像
a+=b;
a=a+b;
等等。0x100是256的十六进制表示法;哇,我不敢相信以前没有人问过这个问题。我是基于你搜索时没有找到它的事实。你确实搜索过,是吗?:-)我做了@paxdiablo。我想谷歌在搜索运营商方面没有那么好。无论如何,谢谢;-)“c运营商”会给你无数次点击。