在gcc中,一般是可以通过__attribute__((packed))属性来取消对齐的,昨天在写个小工具是发现在使用code::block+mingw-gcc时却是死活不行了,无奈之下,只有在虚拟机里面使用gcc编译了。
今天差不多忙完了,来查查原因来了,原来MinGW-GCC是默认启动了兼容MS的特性的,
相关的GCC的说明查看http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html
Two attributes are currently defined for i386 configurations: ms_struct and gcc_struct.
ms_struct
gcc_struct
If packed is used on a structure, or if bit-fields are used it may be that the Microsoft ABI packs them differently than GCC normally packs them. Particularly when moving packed data between functions compiled with GCC and the native Microsoft compiler (either via fu