Mingw-gcc结构体取消对齐

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

         在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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值