Reputation: 24439
When I add
#pragma GCC diagnostic error "-Wreturn-type"
the compiler produces warnings, not errors for each missing return
. How can I make it turn this particular warning into an error?
Test code:
#pragma GCC diagnostic error "-Wreturn-type"
int foo(int x)
{
if (x) return 8;
}
int main(int narg, char* arg[])
{
foo(narg);
}
I have tried with
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
i686-apple-darwin10-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.6)
UPDATE: I have tried -Werror=return-type
as suggested by @sastraxi, but it has the same effect.
Upvotes: 3
Views: 1162