编译器为gcc, 编译平台为32为linux 和 32位saloris平台,语言为C++与C混编
(1)unused variable and function
example:
xxx.cpp:54: warning: unused variable 'yyy'.
'BYTE func( INT4, char*)' defined but not used
原因可能是 1.在该变量作用域内该变量未被使用,或者,变量在以#ifdef /#if ndef ~ #endif内部使用。
2.该函数被声明为static,且未在被包含的文件中使用。
可能解决方法:
第一种情况,将未使用的变量删除,或者将变量的声明和定义写在对应的#ifdef /#if ndef ~ #endif内部。
第二种情况,删除未使用的函数,或者,在不出错的情况下,将static去掉。
(2)warning: invalid white space character in directive
example :
"xxx.cpp",line n: warning: invalid white space character in directive
原因可能是因为linux下的换行与windows下的换行符不相同造成的。
可能解决方法:在linux下使用dos2unix命令对文件进行转换。
(3)warning: implicit function declaration
example:"xxx.c", line n: warning: implicit function declaration: func1
原因可能是func1的参数没有找到多个对应的原型文件
可能解决方法:删除多余的头文件
(4)enumeration value 'xxx' not handled in switch
example:xxx.c:3452: warning: enumeration value 'E_SIMU_DEFAULT' not handled in switch
原因可能是switch中的枚举类型参数所对应的枚举值没有被完全处理。
可能解决方法:1.在switch中加上default:break; 2.将未处理的类型全部加break处理
(5)Formal argument parent of type extern "C" aaa in call to bbb(extern "C" aaa) is being passed aaa.
Warning (Anachronism): Formal argument parent of type extern "C" void(*)() in call to dxdpEventLoop(extern "C" void(*)()) is being passed void(*)().
原因是该类型要求是一个c-link的函数,但是传入了一个C++link的函数
可能解决方法: extern “C”
{
aaa;
}
(6) argument #n is incompatible with prototype:
example:
xxx.c", line 2276: warning: argument #1 is incompatible with prototype
原因是传入得参数,在系统中使用了隐式转换
可能解决方法是对该参数进行强制转换。
(7) deprecated conversion from string constant to 'char*'
example:
xxx.c:166: warning: deprecated conversion from string constant to 'char*'
原因可能是将const char*参数传递给char* 参数
解决方法可能是在该string前加(char*)做强制转换。