[問題] C 判斷式的寫法
小弟最近在寫TI DSP 2808的晶片程式,遇到如下問題想請教各位
struct 16bits
{
unsigned int cyan :1; //bit 0
unsigned int yellow :1; //bit 1
...
unsigned int black :1; //bit 15
};
union colorData
{
unsigned int colorBuf;
struct 16bits colorbits;
};
------------------------------------------------------
union colorData myColor;
dosomething...
dosomething...
dosomething...
if (myColor.colorBuf & 0x0003) <====
{
printf("XDDDD");
}
-------------------------------------------------------
想請教大家一下,若是我以後想修改最上面結構bit的位置,
譬如bit0跟bit15互換,但又不想每次修改的時候
都去修改箭頭所指的if判斷式,除了下列
if (myColor.colorbits.cyan || myColor.colorbits.yellow)
這樣寫以外,還有什麼其他的方法嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 223.143.136.88
推
12/31 14:33, , 1F
12/31 14:33, 1F
→
12/31 14:34, , 2F
12/31 14:34, 2F
→
12/31 14:36, , 3F
12/31 14:36, 3F
→
12/31 14:39, , 4F
12/31 14:39, 4F
→
12/31 14:40, , 5F
12/31 14:40, 5F
※ 編輯: showken 來自: 223.143.136.88 (12/31 14:43)
→
12/31 14:42, , 6F
12/31 14:42, 6F
→
12/31 14:42, , 7F
12/31 14:42, 7F
→
12/31 14:44, , 8F
12/31 14:44, 8F
→
12/31 14:44, , 9F
12/31 14:44, 9F
→
12/31 14:46, , 10F
12/31 14:46, 10F
推
12/31 16:09, , 11F
12/31 16:09, 11F
※ 編輯: showken 來自: 223.143.136.88 (12/31 16:30)
→
12/31 16:30, , 12F
12/31 16:30, 12F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 3 篇):
2
12
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章