可能重复:
我可以让GCC在向函数传递过多类型时发出警告吗?
考虑以下测试程序:
static void func(int a)
{
}
int main()
{
unsigned int b = 42;
func(b);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
用gcc编译它:
lol@mac:~/projects$ gcc -Wconversion testit.c testit.c: In function âmainâ: testit.c:11: warning: passing argument 1 of âfuncâ as signed due to prototype lol@mac:~/projects$
但是,在g ++中没有警告!:
lol@mac:~/projects$ g++ -Wconversion testit.c lol@mac:~/projects$
这是什么原因,有没有办法在编译C++代码时得到相同的警告?