There is a structure DateTime: Struct DateTime { Unsigned int year; Unsigned int the month: 4; Unsigned int day: 5; Unsigned int hour: 5; Unsigned int minute: 6 Unsigned int seconde: 6; } a DateTime.
According to the books on the "law of byte alignment," I am so calculate its size:
So the sizeof () calculated for 8, Printed in the xocde indeed,
Involves the anonymous bit-field is as follows: Struct DateTime { Unsigned int year; Unsigned int the month: 4; Unsigned int day: 5; Unsigned int: 0; Unsigned int hour: 5; Unsigned int minute: 6 Unsigned int seconde: 6; } a DateTime.
Books on said: length of 0 bit-field members, forced by a member from a complete machine word (word), began to distribution,
Xcode sizeof calculated at this time on the same size and account books: for 12.
My question is, how to calculate the 12; Because my idea is: The first thought: Anonymous above a domain analysis:
4 * byte + (4 + 5) * bit=32 + 9=41 * bit;
With the above rules should be 6 byte.
Anonymous below:
A total of 17 * bit should get 3 byte.
So should be 6 + 3=9 * byte; .
The second idea: If the "length of 0 bit-field members, forcing a member from a complete machine word (word), began to assign" understand this sentence is:
Anonymous bit-field members of less than 64 * bit above make up for the 64 * bite, so the end result should be 8 + 3=11 * byte.
Struct DateTime { Unsigned int year; Unsigned int the month: 4; Unsigned int day: 5; Unsigned int: 0; Unsigned int hour: 5; Unsigned int minute: 6 Unsigned int seconde: 6; } a DateTime. Your book knowledge are older, 32-bit machine and you said was right not int on the 32 bit that is what you said 4 byte, hardware knowledge from the corresponding hardware environment is not clear