SST  14.0.0
StructuralSimulationToolkit
warnmacros.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2024 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-2024, 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_FORMAT_SECURITY DIAG_DISABLE(format-security)
36 
37 #define DISABLE_WARN_MAYBE_UNINITIALIZED DIAG_DISABLE(uninitialized)
38 
39 #define DISABLE_WARN_STRICT_ALIASING DIAG_DISABLE(strict-aliasing)
40 
41 #define DISABLE_WARN_MISSING_OVERRIDE DIAG_DISABLE(inconsistent-missing-override)
42 
43 #define DISABLE_WARN_DEPRECATED_DECLARATION DIAG_DISABLE(deprecated-declarations)
44 
45 #elif defined(__GNUC__)
46 #define DIAG_COMPILER GCC
47 
48 #define DISABLE_WARN_DEPRECATED_REGISTER
49 
50 #define DISABLE_WARN_FORMAT_SECURITY DIAG_DISABLE(format-security)
51 
52 #define DISABLE_WARN_MAYBE_UNINITIALIZED DIAG_DISABLE(maybe-uninitialized)
53 
54 #define DISABLE_WARN_STRICT_ALIASING DIAG_DISABLE(strict-aliasing)
55 
56 #if ( __GNUC__ >= 5 )
57 #define DISABLE_WARN_MISSING_OVERRIDE DIAG_DISABLE(suggest-override)
58 #else
59 #define DISABLE_WARN_MISSING_OVERRIDE
60 #endif
61 
62 #define DISABLE_WARN_DEPRECATED_DECLARATION DIAG_DISABLE(deprecated-declarations)
63 
64 #else
65 
66 #undef REENABLE_WARNING
67 #define REENABLE_WARNING
68 #define DISABLE_WARN_DEPRECATED_REGISTER
69 #define DISABLE_WARN_FORMAT_SECURITY
70 #define DISABLE_WARN_MAYBE_UNINITIALIZED
71 #define DISABLE_WARN_STRICT_ALIASING
72 #define DISABLE_WARN_MISSING_OVERRIDE
73 #endif
74 
75 #endif