Created
October 8, 2011 01:29
-
-
Save OneSadCookie/1271719 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
OneSadMBP13:Desktop keith$ cat > test.c | |
#include <stdio.h> | |
typedef struct { short a; } S; | |
typedef struct { char a[2]; } T; | |
main(){ | |
printf("short: %zu bytes; aligned to %zu\n", sizeof(S), __alignof__(S)); | |
printf("char[2]: %zu bytes; aligned to %zu\n", sizeof(T), __alignof__(T)); | |
return 0; | |
} | |
OneSadMBP13:Desktop keith$ gcc test.c | |
OneSadMBP13:Desktop keith$ gcc -arch i386 -arch x86_64 test.c | |
OneSadMBP13:Desktop keith$ ./a.out | |
short: 2 bytes; aligned to 2 | |
char[2]: 2 bytes; aligned to 1 | |
OneSadMBP13:Desktop keith$ arch -i386 ./a.out | |
short: 2 bytes; aligned to 2 | |
char[2]: 2 bytes; aligned to 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment