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