4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
10 * Full author contact details are available in file CREDITS.
13 #ifndef LYX_MUTE_WARNING_H
14 #define LYX_MUTE_WARNING_H
16 #if defined(__GNUC__) && !defined(__clang__)
17 /* This macro can be used to stipulate that a given GCC warning is not
18 * relevant in a given block.
20 * The -Wpragmas bit takes care of the case where -W<warn> is not implemented
22 * The idea for PRAGMA_IGNORE has been stolen from
23 * https://stackoverflow.com/questions/45762357/how-to-concatenate-strings-in-the-arguments-of-pragma#comment124444258_45783809
24 * The difficulty is to put the <warn> value inside nested quotes; it is done
25 * using nested macros.
27 # define PRAGMA_IGNORE(x) PRAGMA_IGNORE_1(-W##x)
28 # define PRAGMA_IGNORE_1(x) PRAGMA_IGNORE_2(#x)
29 # define PRAGMA_IGNORE_2(x) PRAGMA_IGNORE_3(GCC diagnostic ignored x)
30 # define PRAGMA_IGNORE_3(x) _Pragma(#x)
31 # define LYX_BEGIN_MUTE_GCC_WARNING(warn) \
32 _Pragma("GCC diagnostic push") \
33 _Pragma("GCC diagnostic ignored \"-Wpragmas\"") \
35 # define LYX_END_MUTE_GCC_WARNING \
36 _Pragma("GCC diagnostic pop")
38 # define LYX_BEGIN_MUTE_GCC_WARNING(warn)
39 # define LYX_END_MUTE_GCC_WARNING