gcc options: warning on non-void functions without a return statement(gcc 选项:在没有 return 语句的非空函数上发出警告)
问题描述
是否有人知道 gcc/g++ 选项会在函数具有非 void 返回值但在其定义中不包含 return 语句时生成错误/警告?
Does anyone know a gcc/g++ option that generates an error/warning if there's a function that has a non-void return value but doesn't contain a return statement in its definition?
例如:
int add(int a, int b)
{
    a+b;
}
非常感谢!
推荐答案
-Wreturn-type.它由 -Wall 启用(您应该始终使用它,以及 -Werror -Wextra).
-Wreturn-type.  It's enabled by -Wall (which you should always be running with, along with -Werror -Wextra).
这篇关于gcc 选项:在没有 return 语句的非空函数上发出警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:gcc 选项:在没有 return 语句的非空函数上发出警告
				
        
 
            
        - 从python回调到c++的选项 2022-11-16
 - 近似搜索的工作原理 2021-01-01
 - 使用/clr 时出现 LNK2022 错误 2022-01-01
 - C++ 协变模板 2021-01-01
 - 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
 - 如何对自定义类的向量使用std::find()? 2022-11-07
 - Stroustrup 的 Simple_window.h 2022-01-01
 - 静态初始化顺序失败 2022-01-01
 - 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
 - STL 中有 dereference_iterator 吗? 2022-01-01
 
						
						
						
						
						
				
				
				
				