c++ - struct size not as expected when using bit fields -


with below code:

struct s { unsigned char b1 : 3; int i; }; 

i can deduce char b1 of 1 byte , using 3 bits of , int 4 bytes when try print out size of s, 8 bytes instead of 5 bytes(1 char+4 int) expected , not understanding obvious. can explain why size of s 8 bytes?


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -