考虑以下测试程序:
static void func(int a)
{
}
int main()
{
unsigned int b = 42;
func(b);
return 0;
}
用 gcc 编译它:
lol@mac:~/projects$ gcc -Wconversion testit.c testit.c:在函数âmainâ中: testit.c:11:警告:由于原型而将 âfuncâ 的参数 1 传递为已签名 大声笑@mac:~/projects$
但是,在 g++ 中没有警告!:
lol@mac:~/projects$ g++ -Wconversion testit.c 大声笑@mac:~/projects$
这是什么原因,在编译 C++ 代码时有没有办法得到同样的警告?