A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
warnings.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2022 Universita' di Firenze, Italy
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
18
*/
19
20
#ifndef NS3_WARNINGS_H
21
#define NS3_WARNINGS_H
22
23
/**
24
* \defgroup warnings Compiler warnings
25
* \ingroup core
26
*
27
* Macros useful to silence compiler warnings on selected code parts.
28
*/
29
30
/**
31
* \ingroup warnings
32
* \def NS_WARNING_POP
33
* Pops the diagnostic warning list from the stack, restoring it to the previous state.
34
* \sa NS_WARNING_PUSH
35
*/
36
37
/**
38
* \ingroup warnings
39
* \def NS_WARNING_PUSH
40
* Push the diagnostic warning list to the stack, allowing it to be restored later.
41
* \sa NS_WARNING_POP
42
*/
43
44
/**
45
* \ingroup warnings
46
* \def NS_WARNING_SILENCE_DEPRECATED
47
* Silences the "-Wdeprecated-declarations" warnings.
48
* \sa NS_WARNING_POP
49
*/
50
51
/**
52
* \ingroup warnings
53
* \def NS_WARNING_SILENCE_MAYBE_UNINITIALIZED
54
* Silences GCC "-Wmaybe-uninitialized" warnings.
55
* \sa NS_WARNING_POP
56
*/
57
58
/**
59
* \ingroup warnings
60
* \def NS_WARNING_PUSH_DEPRECATED
61
* Save the current warning list and disables the ones about deprecated functions and classes.
62
*
63
* This macro can be used to silence deprecation warnings and should be used as a last resort
64
* to silence the compiler for very specific lines of code.
65
* The typical pattern is:
66
* \code
67
* NS_WARNING_PUSH_DEPRECATED;
68
* // call to a function or class that has been deprecated.
69
* NS_WARNING_POP;
70
* \endcode
71
*
72
* This macro is equivalent to
73
* \code
74
* NS_WARNING_PUSH;
75
* NS_WARNING_SILENCE_DEPRECATED;
76
* \endcode
77
*
78
* Its use is, of course, not suggested unless strictly necessary.
79
*/
80
81
/**
82
* \ingroup warnings
83
* \def NS_WARNING_PUSH_MAYBE_UNINITIALIZED
84
* Save the current warning list and disables the ones about possible uninitialized variables.
85
*
86
*
87
* This macro is equivalent to
88
* \code
89
* NS_WARNING_PUSH;
90
* NS_WARNING_SILENCE_MAYBE_UNINITIALIZED;
91
* \endcode
92
*
93
* \sa NS_WARNING_PUSH_DEPRECATED
94
*/
95
96
#if defined(_MSC_VER)
97
// You can find the MSC warning codes at
98
// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-c4000-c5999
99
#define NS_WARNING_PUSH __pragma(warning(push))
100
#define NS_WARNING_SILENCE_DEPRECATED __pragma(warning(disable : 4996))
101
#define NS_WARNING_POP __pragma(warning(pop))
102
103
#elif defined(__GNUC__) || defined(__clang__)
104
// Clang seems to understand these GCC pragmas
105
#define NS_WARNING_PUSH _Pragma("GCC diagnostic push"
)
106
#define NS_WARNING_SILENCE_DEPRECATED \
107
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\""
)
108
#define NS_WARNING_POP _Pragma("GCC diagnostic pop"
)
109
110
#else
111
#define NS_WARNING_PUSH
112
#define NS_WARNING_SILENCE_DEPRECATED
113
#define NS_WARNING_POP
114
115
#endif
116
117
// GCC-specific - Apple's clang pretends to be both...
118
#if defined(__GNUC__) && !defined(__clang__)
119
#define NS_WARNING_SILENCE_MAYBE_UNINITIALIZED \
120
_Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\""
)
121
#else
122
#define NS_WARNING_SILENCE_MAYBE_UNINITIALIZED
123
#endif
124
125
#define NS_WARNING_PUSH_DEPRECATED \
126
NS_WARNING_PUSH; \
127
NS_WARNING_SILENCE_DEPRECATED
128
129
#define NS_WARNING_PUSH_MAYBE_UNINITIALIZED \
130
NS_WARNING_PUSH; \
131
NS_WARNING_SILENCE_MAYBE_UNINITIALIZED
132
133
#endif
/* NS3_WARNINGS_H */
src
core
model
warnings.h
Generated on Tue May 28 2024 23:34:44 for ns-3 by
1.9.6