Sign in to follow this  

question about struct

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

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

This topic is 3553 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this