Skip to main content
gamedev.net
🔒 Locked

bit fields

Started by Nick2048 Jun 1, 2003 at 5:20 PM 0 replies 600+ views
Original Post
Nick2048
Nick2048
Why is it with a struct like this: struct X { unsigned int MyBitField : 3; }; and code like this: cout << sizeof( MyBitField ) << endl; gives me an output of "4" instead of "1" (with VC 6 at least). There is a set of bits and values (of say 3 to 10 bits) packed into a couple of words that I want to access and manipulate. This seems like a great way to do it, but it looks like it won''t work. Or will it?
S1CA
S1CA

Structure padding and alignment. Structure sizes get padded to the size specified in the project settings and whatever was set with #pragma pack
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.