【发布时间】:2012-11-21 05:39:55
【问题描述】:
可以告诉 GCC 它不应该对结构使用填充。这是使用__attribute__((packed)) 完成的。
typedef struct {
uint8_t startSymbol;
uint8_t packetType;
uint32_t deviceId;
uint16_t packetCRC;
} PacketData __attribute__((packed));
但是,最新的 Xcode 使用 LLVM 并且无法识别该属性。如何为 LLVM 定义打包结构?
问题的完整描述可以在here找到
更新 我正在使用适用于 iOS 的 Xcode 4.5.1,它使用 Apple LLVM 4.1 编译器。在上面的代码示例中,我在 Xcode 中收到“'packed' attribute ignored”警告。
【问题讨论】:
-
我是否遗漏了什么或者这是一个非常新的功能删除?上次查,clang支持
__attribute__((packed))... -
clang 支持完全相同的
__attribute__((packed))pragma... -
不知道 :) 我正在使用 Xcode 4.5.1 for iOS,它使用 Apple LLVM 4.1 编译器。
-
@Centurion 我找到了答案,请参阅编辑。
标签: objective-c c struct