level 1
orange9angel
楼主
#if defined(__GNUC__)
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
#define ATTRIBUTE_PACKED __attribute__ ((packed))
#define PRAGMA_PACK 0
#endif
#endif
#if !defined(ATTRIBUTE_PACKED)
#define ATTRIBUTE_PACKED
#define PRAGMA_PACK 1
#endif
#if PRAGMA_PACK
#pragma pack(1)
#endif
typedef struct {
unsigned int x1 : 1;
unsigned int x2 : 1;
unsigned int x3 : 1;
unsigned int x4 : 1;
unsigned int x5 : 1;
unsigned int x6 : 1;
unsigned int x7 : 1;
unsigned int x8 : 1;
} ATTRIBUTE_PACKED playback_type_t;
#if PRAGMA_PACK
#pragma pack()
#endif
gcc编译出来sizeof(playback_type_t)是1字节,vc 编译器一字节对齐了还是4字节,如何能变成一字节?
2011年04月06日 02点04分
1
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
#define ATTRIBUTE_PACKED __attribute__ ((packed))
#define PRAGMA_PACK 0
#endif
#endif
#if !defined(ATTRIBUTE_PACKED)
#define ATTRIBUTE_PACKED
#define PRAGMA_PACK 1
#endif
#if PRAGMA_PACK
#pragma pack(1)
#endif
typedef struct {
unsigned int x1 : 1;
unsigned int x2 : 1;
unsigned int x3 : 1;
unsigned int x4 : 1;
unsigned int x5 : 1;
unsigned int x6 : 1;
unsigned int x7 : 1;
unsigned int x8 : 1;
} ATTRIBUTE_PACKED playback_type_t;
#if PRAGMA_PACK
#pragma pack()
#endif
gcc编译出来sizeof(playback_type_t)是1字节,vc 编译器一字节对齐了还是4字节,如何能变成一字节?