typedef struct{
char t1;
long long t2;
char t3;
}struct_size_test;
printf("sizeof(long long)==[%ld]\n", sizeof(long long));
printf("sizeof(char)==[%ld]\n", sizeof(char));
printf("sizeof(struct_size_test)==[%ld]\n", sizeof(struct_size_test));
The result of struct_size_test in iOS and in OS X gcc is different.
The result in iOS is
sizeof(long long)==[8]
sizeof(char)==[1]
sizeof(struct_size_test)==[24]
But the result in OS X gcc is
sizeof(long long)==[8]
sizeof(char)==[1]
sizeof(struct_size_test)==[16]
I googled this and found some advice that to add "-malign-double" as the gcc compile flag. But it shows
clang: error: unknown argument: '-malign-double' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
Any idea how to sync the structure padding for iOS and OS X? Thanks a lot!