samedi 25 avril 2015

Bit field memory


If i declare something like this

struct S{
  unsigned int bit:4;
}

How is it working?

  1. I allocate 2 bytes in memory(size of structure(got this size from here http://ift.tt/1a6LHjs) but use only 4 bits of it, and other memory in that structure is wasted.
  2. I allocate only 4 bits, nothing more.

I'm very confused about this and can't find any info about this anywhere.


Aucun commentaire:

Enregistrer un commentaire