diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-09-28 11:42:11 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-09-30 15:15:50 +0000 |
commit | 024aaa532ddffdfb063357f31a8d9d662a02eb0f (patch) | |
tree | 78dd5dd92c82d72402ae37a36315e711023a83e7 | |
parent | 5918f712035d198ab3005877fff76660cf125731 (diff) |
Doc: add a how-to for disabling compiler warnings
Change-Id: Ic323ed03ecc3ab71ab69dc444183bb228c023c99
Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
-rw-r--r-- | doc/howtos.qdoc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/doc/howtos.qdoc b/doc/howtos.qdoc index d216ea004..a4252134d 100644 --- a/doc/howtos.qdoc +++ b/doc/howtos.qdoc @@ -48,6 +48,7 @@ \li \l{How do I build against libraries that provide pkg-config files?} \li \l{How do I create application bundles and frameworks on iOS, macOS, tvOS, and watchOS?} \li \l{How do I apply C/C++ preprocessor macros to only a subset of the files in my product?} + \li \l{How do I disable a compiler warning?} \li \l{How do I make the state of my Git repository available to my source files?} \li \l{How do I limit the number of concurrent jobs for the linker only?} \li \l{How do I add QML files to a project?} @@ -521,6 +522,37 @@ } \endcode + \section1 How do I disable a compiler warning? + + You can use the \l {cpp::commonCompilerFlags}{cpp.commonCompilerFlags} property + to pass flags to the compiler. For example, to disable deprecation warnings: + + \code + CppApplication { + // ... + + readonly property bool isMsvc: qbs.toolchain.contains("msvc") + + cpp.commonCompilerFlags: isMsvc ? "/wd4996" : "-Wno-deprecated-declarations" + } + \endcode + + It is also possible to disable all warnings at once by setting the + \l {cpp::commonCompilerFlags}{cpp.warningLevel} property to \c "none". + Usually this approach is discouraged, but it can be useful in some cases, + such as when compiling third party code: + + \code + Group { + cpp.warningLevel: "none" + + files: [ + "3rdparty.h", + "3rdparty.cpp" + ] + } + \endcode + \section1 How do I make the state of my Git repository available to my source files? Add a dependency to the \l{vcs} module to your product: |