当前位置: 技术问答>linux和unix
代码移植时,类型转换的错误提示
来源: 互联网 发布时间:2016-06-23
本文导语: 在移植linux的PPPoE到ARM板上时,出现了下面的类型转换错误: cc1plus: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++ event_tcp.c: In function `EventTcpState* EventTcp_ReadBuf(EventSelector*, int, int, int,...
在移植linux的PPPoE到ARM板上时,出现了下面的类型转换错误:
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++
event_tcp.c: In function `EventTcpState* EventTcp_ReadBuf(EventSelector*, int, int, int, void (*)(EventSelector*, int, char*, int, int, void*), int, void*)':
event_tcp.c:367: error: invalid conversion from `void*' to `EventTcpState*'
event_tcp.c:374: error: invalid conversion from `void*' to `char*'
event_tcp.c: In function `EventTcpState* EventTcp_WriteBuf(EventSelector*, int, char*, int, void (*)(EventSelector*, int, char*, int, int, void*), int, void*)':
event_tcp.c:448: error: invalid conversion from `void*' to `EventTcpState*'
event_tcp.c:455: error: invalid conversion from `void*' to `char*'
event_tcp.c: In function `void EventTcp_Connect(EventSelector*, int, const sockaddr*, socklen_t, void (*)(EventSelector*, int, int, void*), int, void*)':
event_tcp.c:537: error: invalid conversion from `void*' to `EventTcpConnectState*'
make[1]: *** [event_tcp.o] Error 1
PS:在用g++或gcc直接编译是没问题的,可以编译通过并运行起来,用交叉编译工具来就经常会提示这样的错误,
我用的是开源的rp-pppoe-3.10的代码。
问下,可以怎么修改Makefile里面的编译选项,忽略这些错误信息?省得修改每个源代码文件~
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++
event_tcp.c: In function `EventTcpState* EventTcp_ReadBuf(EventSelector*, int, int, int, void (*)(EventSelector*, int, char*, int, int, void*), int, void*)':
event_tcp.c:367: error: invalid conversion from `void*' to `EventTcpState*'
event_tcp.c:374: error: invalid conversion from `void*' to `char*'
event_tcp.c: In function `EventTcpState* EventTcp_WriteBuf(EventSelector*, int, char*, int, void (*)(EventSelector*, int, char*, int, int, void*), int, void*)':
event_tcp.c:448: error: invalid conversion from `void*' to `EventTcpState*'
event_tcp.c:455: error: invalid conversion from `void*' to `char*'
event_tcp.c: In function `void EventTcp_Connect(EventSelector*, int, const sockaddr*, socklen_t, void (*)(EventSelector*, int, int, void*), int, void*)':
event_tcp.c:537: error: invalid conversion from `void*' to `EventTcpConnectState*'
make[1]: *** [event_tcp.o] Error 1
PS:在用g++或gcc直接编译是没问题的,可以编译通过并运行起来,用交叉编译工具来就经常会提示这样的错误,
我用的是开源的rp-pppoe-3.10的代码。
问下,可以怎么修改Makefile里面的编译选项,忽略这些错误信息?省得修改每个源代码文件~
|
這個設置語法檢查級別的開關應該是有的,但是我確實不知道,沒用過,估計你得去查gcc manual了...
樓主查到了記得來貼一下solution啊,我也學習一下,呵呵
|
如果代碼是C++的,試試這樣行不行:
void* ptr;
static_cast(ptr);
void* ptr;
static_cast(ptr);
|
(char*)這樣的強制類型轉換都不行嗎?
|
event_tcp.c:455: error: invalid conversion from `void*' to `char*'
无语了,这样的强制转换都不行。。估计是少库吧
无语了,这样的强制转换都不行。。估计是少库吧
|
我怀疑有可能configure的时候没配好。
|
估计是交叉编译的环境里面少了什么库,你可以检查一下。