【发布时间】:2014-05-22 05:13:01
【问题描述】:
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));
struct_size_test 在 iOS 和 OS X gcc 中的结果是不同的。
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]
我搜索了这个并找到了一些建议,将“-malign-double”添加为 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 的结构填充吗? 非常感谢!
【问题讨论】:
-
你想在这里做什么?如果您尝试使用结构填充,那么您很可能正在尝试一些非常错误或愚蠢的事情。
标签: ios gcc compiler-construction compiler-errors padding