]> git.lyx.org Git - lyx.git/blob - src/support/mute_warning.h
Amend 207eaeee9071cb
[lyx.git] / src / support / mute_warning.h
1 // -*- C++ -*-
2 /**
3  * \file mute_warning.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Georg Baum
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef LYX_MUTE_WARNING_H
14 #define LYX_MUTE_WARNING_H
15
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.
19  *
20  * The -Wpragmas bit takes care of the case where -W<warn> is not implemented
21  *
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.
26  */
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\"") \
34   PRAGMA_IGNORE(warn)
35 #  define LYX_END_MUTE_GCC_WARNING \
36   _Pragma("GCC diagnostic pop")
37 #else
38 #  define LYX_BEGIN_MUTE_GCC_WARNING(warn)
39 #  define LYX_END_MUTE_GCC_WARNING
40 #endif
41
42
43 #endif