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
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.
How can I achieve this?
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]
Actually, it looks like the return-type
flag may be the one you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With