I am looking into the code written by other members and I came across the code shown below:
struct myType
{
int myInt : 1;
int reserved : 31;
};
What is 1 and 31 stands above and when above notation is used?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
These are bit fields. This code means, that
myIntis just one bit andreservedis 31 bitsFor example, on my machine
prints
4(it’s platform dependent). In you’re example, the exact size of the struct is 32bits, but it’s possible the actual size to be different – depends on the alignment