来自Clang的意外输出

Mad*_*n S 1 c++ clang llvm-clang

我一直在测试clang-llvm,看看我的学校IT部门是否值得将它添加到我们学生编程的机器上.对于我们的所有作业,我们需要使用编译g++ -Wall -W -pedantic-errors *.cpp,所以我只是将命令转换为clang++ -Wall -W -pedantic-errors.我得到了一些我没想到的输出:

Attempting to compile...
In file included from test_library.cpp:6:
In file included from ./test_library.h:64:
In file included from ./library.h:167:
./library.hpp:20:23: warning: unused variable 'e' [-Wunused-variable]
    catch(Exception & e)
                      ^
Run Code Online (Sandbox Code Playgroud)

而GCC编译器没有给出catch块中未使用的变量的错误.有什么我可以这样做,以便Clang不会对try/catch块中未使用的变量感到不满,同时保持命令类似于g ++吗?

Clang-LLVM(v2.7)GNU GCC(v4.4.4)Fedora 13

zwo*_*wol 5

我有点同意迈克的观点,但是为了起步,请试试这个:

clang++ -Wall -W -pedantic-errors -Wno-unused-variable
Run Code Online (Sandbox Code Playgroud)

我没有用太多LLVM,但我认为的点[-Wunused-variable]在诊断就是要告诉你,你可以关闭该警告了-Wno-unused-variable.