Thread: bit fields

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    50
    Quote Originally Posted by grumpy View Post
    It probably means the compiler is smart enough to pack b and c into one 32-bit word (which isn't possible if c is 3 bits, as 33 bits won't fit in a 32 bit word). a is in another 32 bit word. With 8-bit bytes, that means sizeof your struct yields 8.
    Then why doesnt it do the same thing when only 1 bit is increased I mean why on increasing size with just one bit it straight away increases the total size by 4 bytes??

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by Saurabh Mehta View Post
    Then why doesnt it do the same thing when only 1 bit is increased I mean why on increasing size with just one bit it straight away increases the total size by 4 bytes??
    Refer post 2.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Bit fields
    By juice in forum C Programming
    Replies: 7
    Last Post: 12-13-2011, 08:38 AM
  2. Bit fields
    By Edelweiss in forum C Programming
    Replies: 5
    Last Post: 08-23-2011, 10:01 AM
  3. Bit fields
    By Perspektyva in forum C++ Programming
    Replies: 13
    Last Post: 11-22-2008, 02:38 PM
  4. bit-fields
    By kps in forum C Programming
    Replies: 9
    Last Post: 09-25-2002, 08:25 PM
  5. Bit fields
    By GaPe in forum C Programming
    Replies: 8
    Last Post: 01-22-2002, 02:01 PM

Tags for this Thread