SST  12.0.0
StructuralSimulationToolkit
warnmacros.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2022 NTESS. Under the terms
4 // of Contract DE-NA0003525 with NTESS, the U.S.
5 // Government retains certain rights in this software.
6 //
7 // Copyright (c) 2009-2022, NTESS
8 // All rights reserved.
9 //
10 // This file is part of the SST software package. For license
11 // information, see the LICENSE file in the top level directory of the
12 // distribution.
13 
14 #ifndef SST_CORE_WARNMACROS_H
15 #define SST_CORE_WARNMACROS_H
16 
17 #define UNUSED(x) x __attribute__((unused))
18 
19 #define DIAG_STR(s) #s
20 #define DIAG_JOINSTR(x, y) DIAG_STR(x##y)
21 #define DIAG_DO_PRAGMA(x) _Pragma(#x)
22 #define DIAG_PRAGMA(compiler, x) DIAG_DO_PRAGMA(compiler diagnostic x)
23 
24 #define DIAG_DISABLE(option) \
25  DIAG_PRAGMA(DIAG_COMPILER, push) \
26  DIAG_PRAGMA(DIAG_COMPILER, ignored DIAG_JOINSTR(-W, option))
27 
28 #define REENABLE_WARNING DIAG_PRAGMA(DIAG_COMPILER, pop)
29 
30 #if defined(__clang__)
31 #define DIAG_COMPILER clang
32 
33 #define DISABLE_WARN_DEPRECATED_REGISTER DIAG_DISABLE(deprecated-register)
34 
35 #define DISABLE_WARN_STRICT_ALIASING DIAG_DISABLE(strict-aliasing)
36 
37 #define DISABLE_WARN_MISSING_OVERRIDE DIAG_DISABLE(inconsistent-missing-override)
38 
39 #define DISABLE_WARN_DEPRECATED_DECLARATION DIAG_DISABLE(deprecated-declarations)
40 
41 #elif defined(__GNUC__)
42 #define DIAG_COMPILER GCC
43 
44 #define DISABLE_WARN_DEPRECATED_REGISTER
45 
46 #define DISABLE_WARN_STRICT_ALIASING DIAG_DISABLE(strict-aliasing)
47 
48 #if ( __GNUC__ >= 5 )
49 #define DISABLE_WARN_MISSING_OVERRIDE DIAG_DISABLE(suggest-override)
50 #else
51 #define DISABLE_WARN_MISSING_OVERRIDE
52 #endif
53 
54 #define DISABLE_WARN_DEPRECATED_DECLARATION DIAG_DISABLE(deprecated-declarations)
55 
56 #else
57 
58 #undef REENABLE_WARNING
59 #define REENABLE_WARNING
60 #define DISABLE_WARN_DEPRECATED_REGISTER
61 #define DISABLE_WARN_STRICT_ALIASING
62 #define DISABLE_WARN_MISSING_OVERRIDE
63 #endif
64 
65 #endif