[Qt-interest] warnings

John Weeks john at wavemetrics.com
Wed Nov 10 01:41:38 CET 2010


On Nov 9, 2010, at 12:16 AM, <Oliver.Knoll at comit.ch> <Oliver.Knoll at comit.ch> wrote:

> Not sure whether there is a "QMake Way" to do that, but you can always pass along compiler-specific flags, such as
> 
>  QMAKE_CXXFLAGS += -Wall -Woverloaded-virtual -Wno-deprecated -Wuninitialized -W...
> 
> (example for gcc)
> 
> This way you can enable/disable the warnings you'd like to see.

Thanks, Oliver. This seems to be the basis for what I want, with a twist added...

It turns out (by experiment) that qmake keeps a variable QMAKE_CXXFLAGS_WARN_ON and QMAKE_CXXFLAGS_WARN_OFF that hold the appropriate flags in case you use config += warn_on or config += warn_off. By default, at least if you're using gcc, it sets QMAKE_CXXFLAGS_WARN_ON to "-Wall -W" and QMAKE_CXXFLAGS_WARN_OFF to "-w". It adds these to QMAKE_CXXFLAGS late in the process, so it's not possible to modify QMAKE_CXXFLAGS in such a way as to not include those flags. Both sets of flags do things I don't want.

So now I have added this to my .pro file:

macx {
	QMAKE_CXXFLAGS_WARN_ON = ""
	QMAKE_CXXFLAGS += -Wno-all
	QMAKE_CXXFLAGS += -Wno-endif-labels
	QMAKE_CXXFLAGS += -Wno-unused-variable
	QMAKE_CXXFLAGS += -Wno-unused-parameter
	QMAKE_CXXFLAGS += -Wno-switch
	QMAKE_CXXFLAGS += -Wtrigraphs
	QMAKE_CXXFLAGS += -Wreturn-type
	QMAKE_CXXFLAGS += -Wnon-virtual-dtor
	QMAKE_CXXFLAGS += -Woverloaded-virtual
	#QMAKE_CXXFLAGS += -Wunused-variable
	#QMAKE_CXXFLAGS += -Wunused-value
	QMAKE_CXXFLAGS += -Wunknown-pragmas
	QMAKE_CXXFLAGS += -Wno-shadow
	QMAKE_CXXFLAGS += -Wno-deprecated-declarations
	QMAKE_CXXFLAGS += -Wno-missing-braces
}

Note the first entry there- I clear out the QMAKE_CXXFLAGS_WARN_ON so that I have complete control over the warnings flags.

Note also that it is conditional on "macx". On Windows I'm using Visual Studio, and these flags are not good when I import the .pro file to make a Visual Studio solution.

I'm now working on a solution to the same problem on Visual Studio.

Regards, John Weeks

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101109/b298f1da/attachment.html 


More information about the Qt-interest-old mailing list