• Advertisement
Sign in to follow this  

question about struct

This topic is 3620 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

struct _GtkGlInit { boolean b : 1; }; "boolean b : 1" <<--- what does this mean??? Thank

Share this post


Link to post
Share on other sites
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