SST 16.0.0
Structural Simulation Toolkit
warnmacros.h
1// -*- c++ -*-
2
3// Copyright 2009-2026 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-2026, 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 [[maybe_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#if ( __clang_major__ >= 12 )
42#define DISABLE_WARN_MISSING_OVERRIDE DIAG_DISABLE(suggest-override)
43#else
44#define DISABLE_WARN_MISSING_OVERRIDE DIAG_DISABLE(inconsistent-missing-override)
45#endif
46
47#define DISABLE_WARN_DEPRECATED_DECLARATION DIAG_DISABLE(deprecated-declarations)
48
49#define DISABLE_WARN_CAST_FUNCTION_TYPE DIAG_DISABLE(cast-function-type)
50
51#define DISABLE_WARN_DANGLING_POINTER DIAG_PRAGMA(DIAG_COMPILER, push)
52
53#define DISABLE_WARN_MISSING_NORETURN DIAG_PRAGMA(DIAG_COMPILER, push)
54
55#elif defined(__GNUC__)
56
57#define DIAG_COMPILER GCC
58
59#define DISABLE_WARN_DEPRECATED_REGISTER DIAG_PRAGMA(DIAG_COMPILER, push)
60
61#define DISABLE_WARN_FORMAT_SECURITY DIAG_DISABLE(format-security)
62
63#define DISABLE_WARN_MAYBE_UNINITIALIZED DIAG_DISABLE(maybe-uninitialized)
64
65#define DISABLE_WARN_STRICT_ALIASING DIAG_DISABLE(strict-aliasing)
66
67#define DISABLE_WARN_MISSING_NORETURN DIAG_DISABLE(missing-noreturn)
68
69#if ( __GNUC__ >= 5 )
70#define DISABLE_WARN_MISSING_OVERRIDE DIAG_DISABLE(suggest-override)
71#else
72#define DISABLE_WARN_MISSING_OVERRIDE DIAG_PRAGMA(DIAG_COMPILER, push)
73#endif
74
75#define DISABLE_WARN_DEPRECATED_DECLARATION DIAG_DISABLE(deprecated-declarations)
76
77#define DISABLE_WARN_CAST_FUNCTION_TYPE DIAG_DISABLE(cast-function-type)
78
79#if ( __GNUC__ >= 12 )
80#define DISABLE_WARN_DANGLING_POINTER DIAG_DISABLE(dangling-pointer)
81#else
82#define DISABLE_WARN_DANGLING_POINTER DIAG_PRAGMA(DIAG_COMPILER, push)
83#endif
84
85#else
86
87#undef REENABLE_WARNING
88#define REENABLE_WARNING
89#define DISABLE_WARN_DEPRECATED_REGISTER
90#define DISABLE_WARN_FORMAT_SECURITY
91#define DISABLE_WARN_MAYBE_UNINITIALIZED
92#define DISABLE_WARN_STRICT_ALIASING
93#define DISABLE_WARN_MISSING_OVERRIDE
94#define DISABLE_WARN_CAST_FUNCTION_TYPE
95#define DISABLE_WARN_DANGLING_POINTER
96#define DISABLE_WARN_MISSING_NORETURN
97
98#endif
99
100#endif