views:

66

answers:

2

I've been testing out clang-llvm to see if it is worth it to mention to my school's IT department to add it to the machines we students program on. For all of our assignments, we are required to compile using g++ -Wall -W -pedantic-errors *.cpp, so I just converted the command to clang++ -Wall -W -pedantic-errors. I got some output that I wasn't expecting:

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)
                      ^

Whereas the GCC compiler does not give an error about unused variables in the catch block. Is there anything I can do so that Clang does not freak out about unused variables in try/catch blocks while keeping the command similar to the g++ one?

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

+3  A: 

I kinda agree with Mike, but for getting-off-the-ground's sake, try this:

clang++ -Wall -W -pedantic-errors -Wno-unused-variable

I haven't used llvm much but I think the point of the [-Wunused-variable] in the diagnostic is to tell you that you can shut that warning up with -Wno-unused-variable.

Zack
This did shut off the warning thanks. I was able to fix the underlying issue and now clang isn't complaining when I don't suppress the unused variable warning.
Madison S
A: 

What's wrong with catching exception with "catch(Exception &)" if you are not using the variable? You compilers AND your code reviewers will be happier.

Alex Emelianov