[問題] struct bit field
不好意思請問一下...我在網路上範例都是直接說出 struct 大小為 4 byte
struct {
unsigned int widthValidated : 1;
unsigned int heightValidated : 1;
} status;
請問有比較詳細的算法嗎?
我的想法是
總共兩個 bit ,但一次存取是 4 byte ,所以後面 padding 30 bit
求出大小為 4 byte
不知道我這樣想對不對....
感謝
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 58.115.110.72
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1463672022.A.2F5.html
→
05/19 23:48, , 1F
05/19 23:48, 1F
→
05/19 23:49, , 2F
05/19 23:49, 2F
→
05/19 23:55, , 3F
05/19 23:55, 3F
→
05/19 23:55, , 4F
05/19 23:55, 4F
推
05/20 01:03, , 5F
05/20 01:03, 5F
→
05/20 05:32, , 6F
05/20 05:32, 6F
→
05/20 05:54, , 7F
05/20 05:54, 7F
→
05/20 05:55, , 8F
05/20 05:55, 8F
→
05/20 10:37, , 9F
05/20 10:37, 9F
→
05/20 10:42, , 10F
05/20 10:42, 10F
→
05/20 11:19, , 11F
05/20 11:19, 11F
→
05/20 18:33, , 12F
05/20 18:33, 12F
→
05/20 18:33, , 13F
05/20 18:33, 13F
→
05/21 00:43, , 14F
05/21 00:43, 14F
→
05/21 00:43, , 15F
05/21 00:43, 15F
→
05/21 09:58, , 16F
05/21 09:58, 16F