缺少返回语句时出错 [英] Error on missing return statement

查看:217
本文介绍了缺少返回语句时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为GCC下缺少的return语句生成错误?

How do I generate an error for a missing return statement under GCC?

cpfsfuse.c:184: warning: no return statement in function returning non-void

我能够返回错误的隐式函数声明code> -Werror-implicit-function-declaration ),我知道一个 -Werror =

I'm able to return errors for implicit function declaration (-Werror-implicit-function-declaration), and I'm aware of a -Werror= switch, but I can't locate an appropriate warning to promote to error status.

如何实现这一目标?

推荐答案

您应该能够使用 -fdiagnostics-show-option 选项来显示 Werror = 切换。摘自博文:

You should be able to use the -fdiagnostics-show-option option to show the correct flag for the Werror= switch. Taken from this blog post:

% gcc -x c -Wall -Wextra -fdiagnostics-show-option -c -o /dev/null - <<EOF
int foo() {
}
EOF
<stdin> In function ‘foo’:
<stdin>:2: warning: control reaches end of non-void function [-Wreturn-type]

实际上, return-type 标志可能就是你想要的标志。

Actually, it looks like the return-type flag may be the one you want.

这篇关于缺少返回语句时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆