How to suppress warnings in qmake for clang++
Hi,
I built Qt 4.8.0 using XCode 4.2. Now i’m trying to build a library which generates many unused variable warnings. I tried to add this lines to library’s pro file but this doesn’t suppress any warnings.
- clang* {
- QMAKE_CXXFLAGS += -Wno-unused-variable -Wno-deprecated-writable-strings
- }
So, how can i suppress these warnings?
10 replies
These warnings are not from a Qt compilation. This is a 3rd party library project which my project is depend on it.
A source code on this library generates thousands of warnings. I don’t want to see these warnings while compiling my project. I disabled these warnings in MSVC compiler using these lines in that library pro file:
- win32-msvc* {
- QMAKE_CXXFLAGS += /wd4100 /wd4101 /wd4102 /wd4189 /wd4996
- }
Now i need to port my project to Mac OS X Lion. And i cannot suppress these warnings.
If possible at all: warnings should be fixed instead of ignored. Seriously. If you are not going to use a variable, be explicit about and either:
- remove the argument completely from the function, or
- remove the name of the argument from the function, or
- use a construct like Q_UNUSED(myVariable) to be explicit about you not using the argument.
But don’t just ignore the warning. Warnings are there for a reason. The may point to more severe issues or may develop into real problems later on.
Thanks for the info but I already know these rule of thumbs. I actually follow these rules. But this is not my project. This is a third party library and i’m not allowed to edit these library’s source code. It’s library writer’s responsibility. I just want to suppress these warnings by editing pro file.
In gcc
- QMAKE_CXXFLAGS = -Wno-unused-variable
Any suggestions?
@koahnig: The fact that Qt triggers a lot of warnings is actually quite annoying. From a code quality perspective, warnings have a urgency similar to errors, IMO. Often the only warnings that are impossible to get rid off are the ones generated by Qt itself.
Yes, I agree completely. The first time I was compiling Qt libs it was a shock to me when seeing the warnings. However, I (have) arranged myself with it.
I am certainly agreeing also with Andre. He is summarizing my coding ethics.
My answer was refering to the compilation of the Qt libs.
On the other hand I find it more than a bit annoying that I have to clatter my code with pragmas for ignoring warnings when a Qt header is included. IMHO that is a nogo, but on an individual basis you are fighting against windmills there.
Here’s my console output for an unexpected warning generation:
- clang++ -c -pipe -Wno-unused-variable -Wno-deprecated-writable-strings -O2 -arch x86_64 -fPIC -Wall -W -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.8.0/mkspecs/unsupported/macx-clang -I. -I/usr/local/Trolltech/Qt-4.8.0/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Trolltech/Qt-4.8.0/include/QtCore -I/usr/local/Trolltech/Qt-4.8.0/include -I. -I. -F/usr/local/Trolltech/Qt-4.8.0/lib -o ltkcpp_genout.o ltkcpp_genout.cpp
- In file included from ltkcpp_genout.cpp:27:
- ./out_ltkcpp.inc:1312:3: warning: unused label 'missing' [-Wunused-label]
- missing:
- ^
- ./out_ltkcpp.inc:1321:33: warning: unused variable 'pType' [-Wunused-variable]
- const CTypeDescriptor * pType;
- ^
As you can see i passed -Wno-unused-variable parameter but clang++ still generates unused-variable error.
You must log in to post a reply. Not a member yet? Register here!





