Which of these should I use to ignore a warning?
#pragma clang diagnostic ignored "-W<warning>"
#pragma GCC diagnostic ignored "-W<warning>"
Both seems to work for me, however which one is the correct to use?
Should I always use the one matching the compiler I'm using?
Generally, you should prefer #pragma GCC
in cases where the pragma is GCC-specific, or is equally applicable to GCC, Clang, and other compilers which try to be GCC-compatible (such as ICC). Use #pragma clang
in cases where the pragma is in some way Clang-specific (such as a diagnostic option which doesn't exist in GCC).