使用EmBitz 编译mbed提示required from 'void WIZnet_Chip::reg_wr(uint16_t, T) [with T = short unsigned int;
来源:互联网 发布:淘宝双十一宣传片 编辑:程序博客网 时间:2024/05/02 06:45
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 'void WIZnet_Chip::reg_wr(uint16_t, T) [with T = short unsigned int; uint16_t = short unsigned int]'
template<typename T> void reg_wr(uint16_t addr, T data) { return reg_wr(addr, 0x04, data); } template<typename T> void reg_wr(uint16_t addr, uint8_t cb, T data) { uint8_t buf[sizeof(T)]; *reinterpret_cast<T*>(buf) = data; for(int i = 0; i < sizeof(buf)/2; i++) { // Little Endian to Big Endian uint8_t t = buf[i]; buf[i] = buf[sizeof(buf)-1-i]; buf[sizeof(buf)-1-i] = t; } spi_write(addr, cb, buf, sizeof(buf)); }
添加 C++ Flags -fno-strict-aliasing
0 0
- 使用EmBitz 编译mbed提示required from 'void WIZnet_Chip::reg_wr(uint16_t, T) [with T = short unsigned int;
- 使用EmBitz编译mbed提示mbed_wait_api.c:(.text.wait+0x0): multiple definition of `wait'
- mbed使用EmBitz 提示warning: .objs\main.o: linker input file unused because linking not done
- _stdcall的说明及error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' t
- public static void Word2Byte(byte[] to, int toIndex, short from) {
- typedef void (*T) (void *);
- int offset = (int)(t*)1 - (int)(singleton *)(t*)1
- int offset = (int)(t*)1 - (int)(singleton *)(t*)1
- 模板函数 为 void maxn(T *,int n)
- 数据类型 -- char , unsigned char = BYTE, short, unsigned short = WORD, long, unsigned long = DWORD, int , unginged int = UINT
- 数据类型 -- char , unsigned char = BYTE, short, unsigned short = WORD, long, unsigned long = DWORD, int , unginged int = UINT
- 数据类型 -- char , unsigned char = BYTE, short, unsigned short = WORD, long, unsigned long = DWORD, int , unginged int = UINT
- 使用GCC4.8 编译android内核提示warning: argument to ‘sizeof’ in ‘void* memset(void*, int, size_t)’
- 解释宏的功能 #define macro1(t, m) ((int)(void*)&(t *)0->m)
- none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'
- 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'
- char,short,int,long,unsigned,signed
- 关于int offset = (int)(T*)1 - (int)(Singleton <T>*)(T*)1;
- MySQL查看和修改字符集的方法
- 排列问题算法-next_permutation,康托编码
- python模块datetime的使用2
- js倒计时时间不准 && css选择器优先级 && promise详解
- Vijos P1218 数字游戏(动态规划,环形DP)
- 使用EmBitz 编译mbed提示required from 'void WIZnet_Chip::reg_wr(uint16_t, T) [with T = short unsigned int;
- JSP显示服务器路径下的图片
- 欢迎使用CSDN-markdown编辑器
- 拖动条SeekBar及星级评分条
- 学习笔记
- svn脚本的简单使用
- Iprobe for Hanic Improved documentation
- 始
- Android Studio NDK 入门教程(5)--Java对象的传递与修改