jjzjj

c++ - GCC 选项 : warning on non-void functions without a return statement

coder 2024-02-07 原文

如果存在具有非空返回值但在其定义中不包含 return 语句的函数,是否有生成错误/警告的 GCC/g++ 选项?

例如:

int add(int a, int b)
{
    a+b;
}

最佳答案

-Wreturn-type .它由 -Wall(您应该始终与 -Werror -Wextra 一起运行)启用。

关于c++ - GCC 选项 : warning on non-void functions without a return statement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9924570/

有关c++ - GCC 选项 : warning on non-void functions without a return statement的更多相关文章

随机推荐