[Qt-interest] warnings

Sean Harmer sean.harmer at maps-technology.com
Wed Nov 10 11:07:31 CET 2010


Hi,

On 10/11/2010 00:41, John Weeks wrote:
>
> On Nov 9, 2010, at 12:16 AM, <Oliver.Knoll at comit.ch
> <mailto:Oliver.Knoll at comit.ch>> <Oliver.Knoll at comit.ch
> <mailto: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
> }

And there you already have pretty much all you need to go into your 
custom mkspec file. In fact probably all you need to do is to customise 
the QMAKE_CXXFLAGS_WARN_ON in your own mkspec file. It is not as 
difficult as you think. The mkspecs are in standard .pro file syntax.

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

Just customise the appropriate mkspec file or better still copy it and 
modify the copy.

Good luck,

Sean



More information about the Qt-interest-old mailing list