SST 15.0
Structural Simulation Toolkit
warnmacros.h
1// -*- c++ -*-
2
3// Copyright 2009-2025 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-2025, 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#elif defined(__GNUC__)
54
55#define DIAG_COMPILER GCC
56
57#define DISABLE_WARN_DEPRECATED_REGISTER DIAG_PRAGMA(DIAG_COMPILER, push)
58
59#define DISABLE_WARN_FORMAT_SECURITY DIAG_DISABLE(format-security)
60
61#define DISABLE_WARN_MAYBE_UNINITIALIZED DIAG_DISABLE(maybe-uninitialized)
62
63#define DISABLE_WARN_STRICT_ALIASING DIAG_DISABLE(strict-aliasing)
64
65#if ( __GNUC__ >= 5 )
66#define DISABLE_WARN_MISSING_OVERRIDE DIAG_DISABLE(suggest-override)
67#else
68#define DISABLE_WARN_MISSING_OVERRIDE DIAG_PRAGMA(DIAG_COMPILER, push)
69#endif
70
71#define DISABLE_WARN_DEPRECATED_DECLARATION DIAG_DISABLE(deprecated-declarations)
72
73#define DISABLE_WARN_CAST_FUNCTION_TYPE DIAG_DISABLE(cast-function-type)
74
75#if ( __GNUC__ >= 12 )
76#define DISABLE_WARN_DANGLING_POINTER DIAG_DISABLE(dangling-pointer)
77#else
78#define DISABLE_WARN_DANGLING_POINTER DIAG_PRAGMA(DIAG_COMPILER, push)
79#endif
80
81#else
82
83#undef REENABLE_WARNING
84#define REENABLE_WARNING
85#define DISABLE_WARN_DEPRECATED_REGISTER
86#define DISABLE_WARN_FORMAT_SECURITY
87#define DISABLE_WARN_MAYBE_UNINITIALIZED
88#define DISABLE_WARN_STRICT_ALIASING
89#define DISABLE_WARN_MISSING_OVERRIDE
90#define DISABLE_WARN_CAST_FUNCTION_TYPE
91#define DISABLE_WARN_DANGLING_POINTER
92
93#endif
94
95#endif