2

In Visual Studio there is an option to tell the compiler to treat warnings as errors, how do I set that using Qt Creator (I'm using VS2008 as the compiler).

sashoalm
  • 75,001
  • 122
  • 434
  • 781
  • [this question](http://stackoverflow.com/q/6614049/2513200) may contain hints. – Hulk Nov 28 '13 at 13:27
  • @Hulk Thanks, but it doesn't say how to enable warnings as errors, only how to specify additional compiler options. – sashoalm Nov 28 '13 at 14:07
  • 1
    Well if you can add compiler options I assume this one will help: http://msdn.microsoft.com/en-us/library/thxezb7y%28v=vs.90%29.aspx – drescherjm Nov 28 '13 at 14:10
  • In case anyone else stumbled across this question when a project was failing to compile but not displaying any actual compile errors and just warnings, there's a good chance one of your pre-build or post-build actions is failing. – kayleeFrye_onDeck Apr 12 '18 at 23:34

3 Answers3

4

For both compilers (VS and MinGW) use:

win32-g++ {
   QMAKE_CXXFLAGS += -Werror
}
win32-msvc*{
   QMAKE_CXXFLAGS += /WX
}
Zitrax
  • 19,036
  • 20
  • 88
  • 110
vitperov
  • 1,347
  • 17
  • 20
3

An alternative to adding "QMAKE_CXXFLAGS+=-Werror" to your .pro file is to add it to build configuration via the "Projects" tab.

adding cxxflag in qt creator

This setting will be stored in .pro.user file.

HeyYO
  • 1,989
  • 17
  • 24
2

I needed to add

QMAKE_CXXFLAGS += /WX

to my .pro file.

sashoalm
  • 75,001
  • 122
  • 434
  • 781