【发布时间】:2009-02-03 03:26:18
【问题描述】:
可能重复:
Can I make GCC warn on passing too-wide types to functions?
考虑以下测试程序:
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++ 代码时得到同样的警告?
【问题讨论】: