小编use*_*768的帖子

gcc和g ++之间的-Wconversion之间的区别

可能重复:
我可以让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++代码时得到相同的警告?

c c++ gcc g++

6
推荐指数
1
解决办法
2333
查看次数

标签 统计

c ×1

c++ ×1

g++ ×1

gcc ×1