警告"warning: type qualifiers ignored on function return type"
2016-12-13 09:32
1471 查看
我用的时候,使用的是:
定义: const uint16_t getfun(void){int a = 1; return a };使用: uint16_t num = getfun();
这时,会告诉你,类型限定符const,在函数返回时被忽视了。 因为你返回的是一个局部变量的值. 没有使用引用,也没有使用指针,你使用const其实没有意义的。所以编译器自动给你忽略了。
如果你把Num定义成变量,然后返回它的引用,加const,就有效果,不会报错了。就是这样的。试验也成功了。
警告: 类型限定符在函数返回类型时被忽视, 如果返回const类型, 即会出现这种警告,删除const, 即可;
如:
[cpp] view
plain copy
print?
//const double _processPornVideo(void); //警告
double _processPornVideo(void);
相关文章推荐
- Qt - 警告"warning: type qualifiers ignored on function return type"
- onsubmit="return myfunction();"
- Discuz7.2 BUG :"Warning: sprintf() [function.sprintf]: Too few arguments in xxxxxxxx/include/discuzcode.func.php on line 369"
- "No previous prototype for function" warning警告错误解决
- Warning -27077: The "vuser_init" section contains web function(s) when the "Simulate a new user on each iteration" Run-Time Setting is ON.
- "No previous prototype for function" warning警告错误
- warning: control reaches end of non-void function [-Wreturn-type]
- \"No previous prototype for function\" warning警告错误
- MDK中问题:warning : type qualifier is meaningless on cast type return 的解决
- TypeError: validator.settings[("on" + event.type)].call is not a function
- "No previous prototype for function" warning警告错误解决
- KeilMDK4.22 编译STM32工程警告:warning: #223-D: function " *** " declared implicitly
- "PHP Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You
- xcode4.2:warning: Semantic Issue: Conflicting distributed object modifiers on return type in impleme
- 关于 overloaded function differs only by return type from 'void __thiscall 与类内实现
- Sqlachemy的警告SAWarning: The IN-predicate on "sns_object.BIZ_ID" was invoked with an empty sequence. This results in a contradiction, which nonetheless can be expensive to evaluate.
- [Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined、vuejs路由使用的问题Error in render function
- warning:function "bsp_read_word" declared implicitly错误原因
- 总结:form中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- 【DRP】——错误提示:"Syntax error on token "function" , delete this token"