1.warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
原因:把const修饰的类型的地址赋值给了别人
解决方法:把被复制的类型加上const修饰,或者把被const修饰的类型的地址强制类型转换
例子:
const int a = 9; int *pa = &a;就会报这个警告!
方法一:const int *pa = &a;
方法二:int *pa = (int *)&a; 这种方法改变了const的“常量特性”
2.warning: passing argument 1 of ‘prtclFile_convertTo_profileValue’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
原因:函数的第1个输入参数’prtclFile_convertTo_profileValue’,把const修饰的类型作为非const类型使用(比如作为函数输入参数)
解决方法:修改函数的入口参数类型为const or 用的时候强制类型转换把const特性去掉
3.warning: passing argument 3 of ‘prtclFile_convertTo_profileValue’ from incompatible pointer type [-Wincompatible-pointer-types]
原因:函数的第3个输入参数’prtclFile_convertTo_profileValue’ ,忽视指针类型不对的问题
解决方法:修改函数的入口参数类型or用的时候强制类型转换
4.warning: variable ‘pObject’ set but not used [-Wunused-but-set-variable]
原因:变量’pObject’初始化了,但是没用到
结局方法:去掉这个变量