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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
7
*/
8
9
#ifndef NS3_WARNINGS_H
10
#define NS3_WARNINGS_H
11
12
/**
13
* \defgroup warnings Compiler warnings
14
* \ingroup core
15
*
16
* Macros useful to silence compiler warnings on selected code parts.
17
*/
18
19
/**
20
* \ingroup warnings
21
* \def NS_WARNING_POP
22
* Pops the diagnostic warning list from the stack, restoring it to the previous state.
23
* \sa NS_WARNING_PUSH
24
*/
25
26
/**
27
* \ingroup warnings
28
* \def NS_WARNING_PUSH
29
* Push the diagnostic warning list to the stack, allowing it to be restored later.
30
* \sa NS_WARNING_POP
31
*/
32
33
/**
34
* \ingroup warnings
35
* \def NS_WARNING_SILENCE_DEPRECATED
36
* Silences the "-Wdeprecated-declarations" warnings.
37
* \sa NS_WARNING_POP
38
*/
39
40
/**
41
* \ingroup warnings
42
* \def NS_WARNING_SILENCE_MAYBE_UNINITIALIZED
43
* Silences GCC "-Wmaybe-uninitialized" warnings.
44
* \sa NS_WARNING_POP
45
*/
46
47
/**
48
* \ingroup warnings
49
* \def NS_WARNING_PUSH_DEPRECATED
50
* Save the current warning list and disables the ones about deprecated functions and classes.
51
*
52
* This macro can be used to silence deprecation warnings and should be used as a last resort
53
* to silence the compiler for very specific lines of code.
54
* The typical pattern is:
55
* \code
56
* NS_WARNING_PUSH_DEPRECATED;
57
* // call to a function or class that has been deprecated.
58
* NS_WARNING_POP;
59
* \endcode
60
*
61
* This macro is equivalent to
62
* \code
63
* NS_WARNING_PUSH;
64
* NS_WARNING_SILENCE_DEPRECATED;
65
* \endcode
66
*
67
* Its use is, of course, not suggested unless strictly necessary.
68
*/
69
70
/**
71
* \ingroup warnings
72
* \def NS_WARNING_PUSH_MAYBE_UNINITIALIZED
73
* Save the current warning list and disables the ones about possible uninitialized variables.
74
*
75
*
76
* This macro is equivalent to
77
* \code
78
* NS_WARNING_PUSH;
79
* NS_WARNING_SILENCE_MAYBE_UNINITIALIZED;
80
* \endcode
81
*
82
* \sa NS_WARNING_PUSH_DEPRECATED
83
*/
84
85
#if defined(_MSC_VER)
86
// You can find the MSC warning codes at
87
// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-c4000-c5999
88
#define NS_WARNING_PUSH __pragma(warning(push))
89
#define NS_WARNING_SILENCE_DEPRECATED __pragma(warning(disable : 4996))
90
#define NS_WARNING_POP __pragma(warning(pop))
91
92
#elif defined(__GNUC__) || defined(__clang__)
93
// Clang seems to understand these GCC pragmas
94
#define NS_WARNING_PUSH _Pragma("GCC diagnostic push")
95
#define NS_WARNING_SILENCE_DEPRECATED \
96
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
97
#define NS_WARNING_POP _Pragma("GCC diagnostic pop")
98
99
#else
100
#define NS_WARNING_PUSH
101
#define NS_WARNING_SILENCE_DEPRECATED
102
#define NS_WARNING_POP
103
104
#endif
105
106
// GCC-specific - Apple's clang pretends to be both...
107
#if defined(__GNUC__) && !defined(__clang__)
108
#define NS_WARNING_SILENCE_MAYBE_UNINITIALIZED \
109
_Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
110
#else
111
#define NS_WARNING_SILENCE_MAYBE_UNINITIALIZED
112
#endif
113
114
#define NS_WARNING_PUSH_DEPRECATED \
115
NS_WARNING_PUSH; \
116
NS_WARNING_SILENCE_DEPRECATED
117
118
#define NS_WARNING_PUSH_MAYBE_UNINITIALIZED \
119
NS_WARNING_PUSH; \
120
NS_WARNING_SILENCE_MAYBE_UNINITIALIZED
121
122
#endif
/* NS3_WARNINGS_H */
src
core
model
warnings.h
Generated on Wed Oct 9 2024 01:03:23 for ns-3 by
1.11.0