Created
March 3, 2010 01:22
-
-
Save maluta/320194 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Struct1 { | |
unsigned int a0; | |
unsigned int a1; | |
unsigned int a2; | |
unsigned int a3; | |
}; | |
struct Struct2 { | |
unsigned int a0 : 1; | |
unsigned int a1 : 1; | |
unsigned int a2 : 2; | |
unsigned int a3 : 4; | |
}; | |
struct Struct3 { | |
unsigned int a0 : 1; | |
unsigned int a1 : 1; | |
unsigned int a2 : 2; | |
unsigned int a3 : 4; | |
} __attribute__((__packed__)); | |
int main(int argc, char *argv[]) { | |
struct Struct1 a; /* sizeof(a) = 16 bytes */ | |
struct Struct2 b; /* sizeof(b) = 4 bytes */ | |
struct Struct3 c; /* sizeof(c) = 1 byte */ | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment