Jump to content
  • Advertisement
Sign in to follow this  
Neon2302

question about struct

This topic is 3744 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Quote:
Original post by Neon2302
"boolean b : 1" <<--- what does this mean???

Thank


Bit Fields

Also, bit fields cannot be of type bool, although this may be compiler dependent.

Share this post


Link to post
Share on other sites
It's a bit field.

The intent seems to be to create a boolean that takes up only 1 bit. I'm pretty sure, however, that the whole struct must take up at least a byte no matter what. Perhaps someone more knowledgeable can clarify.

Share this post


Link to post
Share on other sites
Quote:
Original post by Crypter
Also, bit fields cannot be of type bool, although this may be compiler dependent.

Yes, they can. See section 9.6 paragraph 4 of the C++ standard.

Quote:
Original post by Simian Man
The intent seems to be to create a boolean that takes up only 1 bit. I'm pretty sure, however, that the whole struct must take up at least a byte no matter what. Perhaps someone more knowledgeable can clarify.

Yes, structs must always have a sizeof of at least 1.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
Quote:
Original post by Crypter
Also, bit fields cannot be of type bool, although this may be compiler dependent.

Yes, they can. See section 9.6 paragraph 4 of the C++ standard.

My mistake--you are absolutely correct. Thanks for pointing that out.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!