I have the following C code, which returns a value from a void function.
void foo() {
// do something
return 0;
}
int main() {
foo();
return 0;
}
I expect this code to fail compilation and Clang fails with an error. However, MSVC allows this with a warning: warning C4098: 'foo': 'void' function returning a value
I would like Clang to behave as MSVC does. Is there a way to configure Clang such that it will also allow this? I've tried clang-cl and the flag -fms-compatibility to no avail.
It is quite easy.
Add to your command line -Wno-error=return-type
Example: https://godbolt.org/z/P4vePWEcT
It will not treat this warning as an error.