在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 comp

本文介绍了在使用Mingw-gcc时遇到的结构体对齐问题,通常通过__attribute__((packed))取消对齐在GCC中有效,但针对Mingw-gcc,由于默认启用MS兼容特性,需要使用__attribute__((gcc_struct, packed))来实现相同功能。详细信息可参考GCC官方文档。"
90812494,7517281,增强现实技术详解:从理论到实践,"['增强现实', '计算机视觉', '三维重建', 'SLAM', '相机模型']
4271

被折叠的 条评论
为什么被折叠?



