使用EmBitz 编译mbed提示required from 'void WIZnet_Chip::reg_wr(uint16_t, T) [with T = short unsigned int;

当使用EmBitz编译mbed项目且优化级别大于等于2时,会遇到strict-aliasing问题导致编译错误。通过添加编译标志'-fno-strict-aliasing'可以禁止strict-aliasing,从而解决这个问题。
摘要由CSDN通过智能技术生成

If optimization level is >= 2 in gcc-4.1, strict-aliasing is used, and this could cause probelms when a pointer is referencing to a different type of object and the object is refered thereafter by using this pointer. That is the case in this example. So you should force the compiler to not use strict-aliasing by a argument "-fno-strict-aliasing" if you want to use "-O2" or "-O3".

就是说 optimization level>=2 默认使用 strict-aliasing, -O0和-O1就没有默认使用 -fstrict-aliasing,导致不同类型的指针指向同一内存就会提示错误。比如:

int i=1;
unsigned int * p=(unsigned int *)(&i);
这样是不符合 aliasing规则的。如果使用 -O2 或 -O3 可以使用参数 -fno-strict-aliasing来避免aliasing规则。上面的代码就可以通过编译了。


使用EmBitz 编译mbed提示

.\W5500Interface\WIZnet\W5500.h|321|  required from 'vo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值