diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-05-02 08:21:23 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-05-06 02:41:06 +0200 |
commit | c95fd3a7ce9c33f1fca1bce02e2f3b4cfdddc96c (patch) | |
tree | 4497898f52b62cd033ea150e28687998e7ce0374 /src/plugins | |
parent | 02c2ad6cbea5b9c3e8da5a23bdbb402357dba0f0 (diff) |
qcompilerdetection.h: add Q_CC_{GNU,MSVC,CLANG}_ONLY macros
As the standard compilers on their respective platforms, other
compilers tend to mask as Clang, GCC, or MSVC, leading to complicated
code when you actually mean just one of these compilers:
#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
This is particularly problematic when combined with version checks:
#if defined(Q_CC_GNU) && Q_CC_GNU >= 900
will, e.g., not match Clang 10.0.0, which masks as GCC 4.2. The
correct way (until a new kid on the block starts to mask as GCC, too)
to check for GCC >= 9.0 atm is:
#if defined(Q_CC_CLANG) || defined(Q_CC_INTEL) || !(defined(Q_CC_GNU) && Q_CC_GNU >= 900)
The new macros make such checks intuitive and hard-to-misuse:
#if defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 900
Use it in qcompilerdetection.h.
Pick-to: 6.3 6.2 5.15
Change-Id: Idcdf973fbc4708f58ed91c800be3d5e599e5b7e6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/plugins')
0 files changed, 0 insertions, 0 deletions