core: (fixes #819) disable deprecation warnings for Object registration
This commit is contained in:
@@ -20,6 +20,7 @@ Changes from ns-3.37 to ns-3.38
|
||||
|
||||
* (network) Add class `TimestampTag` for associating a timestamp with a packet.
|
||||
* (wifi) Added a new attribute **NMaxInflights** to QosTxop to set the maximum number of links on which an MPDU can be simultaneously in-flight.
|
||||
* (core) Added several macros in **warnings.h** to silence compiler warnings in specific sections of code. Their use is discouraged, uness really necessary.
|
||||
|
||||
### Changes to existing API
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ Release 3-dev
|
||||
- (network) !1163 - Initializing an Ipv[4,6]Address from an invalid string do not raise an exception anymore. Instead the address is marked as not initialized.
|
||||
- (internet) !1186 - `TcpWestwood` model has been removed, and the class has been renamed `TcpWestwoodPlus`.
|
||||
- (internet) !1229 - You can now ping broadcast addresses.
|
||||
- (core) !1236 - Added some macros to silence compiler warnings. The new macros are in **warnings.h**, and their use is not suggested unless for very specific cases.
|
||||
|
||||
### Bugs fixed
|
||||
|
||||
@@ -30,6 +31,7 @@ Release 3-dev
|
||||
- (network) !1229 - Fixed a bug in `Ipv4Address::IsSubnetDirectedBroadcast`
|
||||
- (internet) !1229 - Fixed a bug in `Icmpv4Header::HandleEcho` when replying to broadcast-type Echo requests, and two bugs in `Ipv4RawSocketImpl::SendTo` in handling sockets bound to a specific address and directed to a broadcast-type address.
|
||||
- (internet) - `NeighborCacheHelper::PopulateNeighborCache` is now robust against missing IPv4 or IPv6 stack in nodes.
|
||||
- (core) !1236 - Deprecation warnings are silenced while calling `NS_OBJECT_ENSURE_REGISTERED`
|
||||
|
||||
Release 3.37
|
||||
------------
|
||||
|
||||
@@ -309,6 +309,7 @@ set(header_files
|
||||
model/unused.h
|
||||
model/valgrind.h
|
||||
model/vector.h
|
||||
model/warnings.h
|
||||
model/watchdog.h
|
||||
model/realtime-simulator-impl.h
|
||||
model/wall-clock-synchronizer.h
|
||||
|
||||
@@ -60,6 +60,15 @@
|
||||
* void SomethingUseful () { ... }
|
||||
* \endcode.
|
||||
*
|
||||
* \note Sometimes it is necessary to silence a deprecation warning.
|
||||
* Even though this is highly discouraged, if necessary it is possible to use:
|
||||
* \code
|
||||
* NS_WARNING_PUSH_DEPRECATED;
|
||||
* // call to a function or class that has been deprecated.
|
||||
* NS_WARNING_POP;
|
||||
* \endcode
|
||||
* These macros are defined in warnings.h
|
||||
*
|
||||
* \param msg Optional message to add to the compiler warning.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "callback.h"
|
||||
#include "type-id.h"
|
||||
#include "warnings.h"
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
@@ -47,9 +48,11 @@
|
||||
{ \
|
||||
Object##type##RegistrationClass() \
|
||||
{ \
|
||||
NS_WARNING_PUSH_DEPRECATED; \
|
||||
ns3::TypeId tid = type::GetTypeId(); \
|
||||
tid.SetSize(sizeof(type)); \
|
||||
tid.GetParent(); \
|
||||
NS_WARNING_POP; \
|
||||
} \
|
||||
} Object##type##RegistrationVariable
|
||||
|
||||
|
||||
86
src/core/model/warnings.h
Normal file
86
src/core/model/warnings.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Universita' di Firenze, Italy
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
|
||||
*/
|
||||
|
||||
#ifndef NS3_WARNINGS_H
|
||||
#define NS3_WARNINGS_H
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* \def NS_WARNING_POP
|
||||
* Pops the diagnostic warning list from the stack, restoring it to the previous state.
|
||||
* \sa NS_WARNING_PUSH
|
||||
*/
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* \def NS_WARNING_PUSH
|
||||
* Push the diagnostic warning list to the stack, allowing it to be restored later.
|
||||
* \sa NS_WARNING_POP
|
||||
*/
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* \def NS_WARNING_SILENCE_DEPRECATED
|
||||
* Silences the "-Wdeprecated-declarations" warnings.
|
||||
* \sa NS_WARNING_POP
|
||||
*/
|
||||
|
||||
/**
|
||||
* \ingroup core
|
||||
* \def NS_WARNING_PUSH_DEPRECATED
|
||||
* Save the current warning list and disables the ones about deprecated functions and classes.
|
||||
*
|
||||
* This macro can be used to silence deprecation warnings and should be used as a last resort
|
||||
* to silence the compiler for very specific lines of code.
|
||||
* The typical pattern is:
|
||||
* \code
|
||||
* NS_WARNING_PUSH_DEPRECATED;
|
||||
* // call to a function or class that has been deprecated.
|
||||
* NS_WARNING_POP;
|
||||
* \endcode
|
||||
*
|
||||
* Its use is, of course, not suggested unless strictly necessary.
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// You can find the MSC warning codes at
|
||||
// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-c4000-c5999
|
||||
#define NS_WARNING_PUSH __pragma(warning(push))
|
||||
#define NS_WARNING_SILENCE_DEPRECATED __pragma(warning(disable : 4996))
|
||||
#define NS_WARNING_POP __pragma(warning(pop))
|
||||
|
||||
#elif defined(__GNUC__) || defined(__clang__)
|
||||
// Clang seems to understand these GCC pragmas
|
||||
#define NS_WARNING_PUSH _Pragma("GCC diagnostic push")
|
||||
#define NS_WARNING_SILENCE_DEPRECATED \
|
||||
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
||||
#define NS_WARNING_POP _Pragma("GCC diagnostic pop")
|
||||
|
||||
#else
|
||||
#define NS_WARNING_PUSH
|
||||
#define NS_WARNING_SILENCE_DEPRECATED
|
||||
#define NS_WARNING_POP
|
||||
|
||||
#endif
|
||||
|
||||
#define NS_WARNING_PUSH_DEPRECATED \
|
||||
NS_WARNING_PUSH; \
|
||||
NS_WARNING_SILENCE_DEPRECATED
|
||||
|
||||
#endif /* NS3_WARNINGS_H */
|
||||
Reference in New Issue
Block a user