Add WS_DEPRECATED_X() function attribute

This adds a new attribute that allows declaring Wireshark
functions as deprecated.

Also disabe -Werror with deprecated declarations  Deprecated
declarations can be introduced suddenly with a new version
of an external dependency or a new internal deprecation and
that has its own timeline to fix. We should still be able to
build with -Werror in that case.
This commit is contained in:
João Valverde 2022-10-10 11:41:15 +01:00
parent 3b803a94c7
commit 1b12dc4b9e
3 changed files with 28 additions and 2 deletions

View File

@ -669,6 +669,13 @@ else() # ! MSVC
# seem to flag very interesting issues.
#
-Wno-format-truncation
#
# Updating external dependencies can introduce new deprecations.
# Also fixing new internal deprecations takes time.
# We want to be able to build with -Werror in that case. New
# code should not introduce new deprecations in any case.
#
-Wno-error=deprecated-declarations
)
#

View File

@ -75,6 +75,27 @@ extern "C" {
#define WS_RETNONNULL
#endif
/*
* WS_DEPRECATED, before a function declaration, means "this function
* should not be used anymore and will be removed in a future version".
* WS_DEPRECATED_X() optionally takes a message saying what should be done
* instead (strongly recommended).
*
* This is not implemented on purpose with MSVC because that compiler has no
* equivalent to -Wno-error=deprecated-declarations, making it impossible
* to build with -Werror and deprecated declarations. The Microsoft developer
* team seems to not understand the requirement.
* https://developercommunity.visualstudio.com/t/cant-treat-deprecated-warning-as-warning-with-wx/786502
* https://developercommunity.visualstudio.com/t/impossible-to-treat-warning-as-error-except-specif/473936
*/
#if __has_attribute(deprecated)
#define WS_DEPRECATED __attribute__((deprecated))
#define WS_DEPRECATED_X(msg) __attribute__((deprecated(msg)))
#else
#define WS_DEPRECATED
#define WS_DEPRECATED_X(msg)
#endif
/*
* WS_THREAD_LOCAL means "this variable should go in thread-local
* storage.

View File

@ -155,9 +155,7 @@ void DragDropTabBar::mouseMoveEvent(QMouseEvent *event)
_dragInitiated = true;
if ((event->buttons() & Qt::LeftButton) && _dragInitiated) {
DIAG_WARN(deprecated-declarations)
QMouseEvent * finishMouseMove = new QMouseEvent(QEvent::MouseMove, event->pos(), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
DIAG_ON(deprecated-declarations)
QTabBar::mouseMoveEvent(finishMouseMove);
QDrag * drag = new QDrag(this);