警告"warning: type qualifiers ignored on function return type"
来源:互联网 发布:阿里云华东 编辑:程序博客网 时间:2024/05/22 17:28
我用的时候,使用的是:
定义: const uint16_t getfun(void){int a = 1; return a };
使用: uint16_t num = getfun();
这时,会告诉你,类型限定符const,在函数返回时被忽视了。 因为你返回的是一个局部变量的值. 没有使用引用,也没有使用指针,你使用const其实没有意义的。所以编译器自动给你忽略了。
如果你把Num定义成变量,然后返回它的引用,加const,就有效果,不会报错了。就是这样的。试验也成功了。
警告: 类型限定符在函数返回类型时被忽视, 如果返回const类型, 即会出现这种警告,删除const, 即可;
如:
0 0
- Qt - 警告"warning: type qualifiers ignored on function return type"
- 警告"warning: type qualifiers ignored on function return type"
- warning:discards qualifiers from pointer target type
- warning: assignment discards qualifiers from pointer target type
- MDK中问题:warning : type qualifier is meaningless on cast type return 的解决
- JNI WARNING: CallObjectMethod expected return type 'L'
- xcode4.2:warning: Semantic Issue: Conflicting distributed object modifiers on return type in impleme
- discards qualifiers || new types may not be defined in a return type|| shadows a parameter
- function should return a value; 'void' return type assumed
- 解决JNI WARNING: expected return type 'L'的问题
- error: conflicting type qualifiers for 'xxxxx'
- Type Qualifiers in C and C++
- warning C4518: '__int64 ' : storage-class or type specifier(s) unexpected here; ignored
- warning C6031: Return value ignored: 'GetLastError'
- warning: control reaches end of non-void function [-Wreturn-type]
- warning: control reaches end of non-void function [-Wreturn-type]
- const member function can return non-const type member vars
- 异常规范的警告(vs2005):warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
- spring(基础16) Spring No adapter for handler异常
- 【Web前端】各种宽高的作用
- Docker基础
- 香港四大天王影帝情况(截止2016)
- LeetCode笔记:303. Range Sum Query - Immutable
- 警告"warning: type qualifiers ignored on function return type"
- webrtc编译好的国内包
- bzoj 2653: middle (二分+主席树)
- 进程组和组长进程
- ubuntu安装软件的管理
- js的闭包(二)——闭包的机理之我见
- 吃鸡腿
- Retrofit+RxJava完美封装(二)
- SDL_CDStop函数