Qt compiler flags order

My goal is to get rid of some types of compiler warnings. I found out that I can do this by adding compiler flags to the .pro file:

QMAKE_CXXFLAGS += -Wno-unused-variable -Wno-reorder 

The problem is that they are added before the flags that are generated by the Qt build system. I reviewed my compiler output:

g ++ - 4.2 -c -pipe -Wno-unused-variable -Wno-reorder -g -gdwarf-2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min = 10.5 -Wall -W -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB

So, as you can see, -Wall goes after my flags and discards them. What to do to add these flags after?

+3
source share
1 answer

Do not use QMAKE_CXXFLAGS , but rather override QMAKE_CXXFLAGS_WARN_ON with your own warnings:

 QMAKE_CXXFLAGS_WARN_ON = -Wno-unused-variable -Wno-reorder 
+4
source

Source: https://habr.com/ru/post/1493325/


All Articles