Qt: Clean up the byte view hover highlight.
[metze/wireshark/wip.git] / ws_diag_control.h
1 /* ws_diag_control.h
2  * Turn compiler diagnostic messages on and off.
3  *
4  * From FreeRADIUS build.h.
5  *
6  * @copyright 2013 The FreeRADIUS server project
7  *
8  * That project is covered by the GPLv2, so:
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24 #ifndef __WS_DIAG_CONTROL_H__
25 #define __WS_DIAG_CONTROL_H__
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 #define XSTRINGIFY(x) #x
32
33 /*
34  *      Macros for controlling warnings in GCC >= 4.2 and clang >= 2.8
35  */
36 #define DIAG_JOINSTR(x,y) XSTRINGIFY(x ## y)
37 #define DIAG_DO_PRAGMA(x) _Pragma (#x)
38
39 /* check the gcc or clang version
40
41    pragma GCC diagnostic error/warning/ignored -Wxxx was introduced
42    in gcc 4.2.0
43    pragma GCC diagnostic push/pop was introduced in gcc 4.6.0
44
45    pragma clang diagnostic error/warning/ignored -Wxxx and
46    pragma clang diagnostic push/pop were introduced in clang 2.8 */
47
48 #if defined(__GNUC__) && !defined(__clang__)
49 #  define gcc_version ((__GNUC__ * 1000) + (__GNUC_MINOR__ * 10))
50 #  if gcc_version >= 4080
51      /*
52       * gcc version is >= 4.8.0. We can use "GCC diagnostic push/pop" *and*
53       * gcc supports "-Wpedantic".
54       */
55 #    define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x)
56 #    define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
57 #    define DIAG_ON(x) DIAG_PRAGMA(pop)
58 #  endif
59 #elif defined(__clang__)
60 #  define clang_version ((__clang_major__ * 1000) + (__clang_minor__ * 10))
61 #  if clang_version >= 2080
62      /* clang version is >= 2.8: we can use "clang diagnostic ignored -Wxxx"
63         and "clang diagnostic push/pop" */
64 #    define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x)
65 #    define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
66 #    define DIAG_ON(x) DIAG_PRAGMA(pop)
67 #  endif
68 #endif
69
70 /* Use for clang specific pragmas, so we can keep -Wpragmas enabled */
71 #ifdef __clang__
72 #  define DIAG_OFF_CLANG(x) DIAG_OFF(x)
73 #  define DIAG_ON_CLANG(x)  DIAG_ON(x)
74 #else
75 #  define DIAG_OFF_CLANG(x)
76 #  define DIAG_ON_CLANG(x)
77 #endif
78
79 #ifndef DIAG_OFF
80    /* no gcc or clang, or gcc version < 4.2.0, or clang version < 2.8:
81       we can't do anything */
82 #  define DIAG_OFF(x)
83 #  define DIAG_ON(x)
84 #endif
85
86 /*
87  *      For dealing with APIs which are only deprecated in OS X (like the
88  *      OpenSSL and MIT/Heimdal Kerberos APIs).
89  *
90  *      Dear Apple: this is a cross-platform program, and we're not
91  *      going to use your Shiny New Frameworks on OS X unless there's
92  *      a sufficiently clear benefit to make it worth our while to have
93  *      both OS X and non-OS X versions of the code.
94  */
95 #ifdef __APPLE__
96 #  define USES_APPLE_DEPRECATED_API DIAG_OFF(deprecated-declarations)
97 #  define USES_APPLE_RST DIAG_ON(deprecated-declarations)
98 #else
99 #  define USES_APPLE_DEPRECATED_API
100 #  define USES_APPLE_RST
101 #endif
102
103 #ifdef __cplusplus
104 }
105 #endif
106 #endif /* __WS_DIAG_CONTROL_H__ */