everyone here. In my opinion, the calculation below is correct. 1byte(8bit) 2byte(16bit) 2byte(16bit) 3byte(24bit) = 8byte(64bit) However, when I checked using sizeof in Windows and Ubuntu environments, I returned 10 bytes. I'm so curious about the reason.
version g++ 11.4.0 ubuntu 22.04, windows
struct request{
unsigned char bit_a:1;
unsigned char bit_b: 2;
unsigned char bit_c: 1;
unsigned char bit_d:4;
unsigned short bit_short_a;
unsigned short bit_short_b;
unsigned char bit_arr\[3\];
};
std::cout \<\< sizeof(request) \<\<std::endl;
Expected output
8
Actual output
10