It's possible to tell GCC it should not use padding for the struct. This is done using __attribute__((packed))
.
typedef struct {
uint8_t startSymbol;
uint8_t packetType;
uint32_t deviceId;
uint16_t packetCRC;
} PacketData __attribute__((packed));
However, newest Xcode uses LLVM and does not recognize the attribute. How to define packed struct for LLVM?
The full description of the problem might be found here
UPDATE I'm using Xcode 4.5.1 for iOS which uses Apple LLVM 4.1 compiler. I'm getting "'packed' attribute ignored" warning in Xcode in the code example above.