c++ - Bit field memory -


if declare this

struct s{   unsigned int bit:4; } 

how working?

  1. i allocate 2 bytes in memory(size of structure(got size here http://en.cppreference.com/w/cpp/language/bit_field) use 4 bits of it, , other memory in structure wasted.
  2. i allocate 4 bits, nothing more.

i'm confused , can't find info anywhere.

when write

s s; 

you allocate sizeof (s) bytes, seems 2 in case.
fact use 4 bits of space not change size.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -