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));
iOS和OS X gcc中struct_size_test的结果是不同的。
在iOS的结果是结构填充编译标志
sizeof(long long)==[8]
sizeof(char)==[1]
sizeof(struct_size_test)==[24]
但结果在OS X GCC是
sizeof(long long)==[8]
sizeof(char)==[1]
sizeof(struct_size_test)==[16]
我GOOGLE了这一点,并发现了一些建议,增加“-malign双”的GCC编译标志。 但它显示
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
任何想法如何同步iOS和OS X结构的填充? 非常感谢!
你想在这里做什么?如果你正在尝试使用结构打包技术,那么很可能你正在尝试一些非常错误或愚蠢的事情。 – gnasher729