Qt编译器标志顺序
我的目标是摆脱一些类型的编译器警告。我发现我可以这样做,通过在我的.pro文件中添加编译器标志:
My goal is to get rid of some types of compiler warnings. I found out that I can do that by adding compiler flags in my .pro file:
QMAKE_CXXFLAGS += -Wno-unused-variable -Wno-reorder
问题是,它们是在Qt构建系统生成的标志之前添加的。我检查了我的编译器输出:
The problem is that they are added before flags that are generated by Qt build system. I've examined 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
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 should I do to add those flags after ?
不要使用 QMAKE_CXXFLAGS
,而是重写 QMAKE_CXXFLAGS_WARN_ON
并附上您自己的警告:
Don't use QMAKE_CXXFLAGS
but rather override QMAKE_CXXFLAGS_WARN_ON
with your own warnings:
QMAKE_CXXFLAGS_WARN_ON = -Wno-unused-variable -Wno-reorder