From f3864e9abbc107738eb3824e1181dcbc26335b11 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Mon, 24 Dec 2018 23:14:24 -0800 Subject: [PATCH] Move deprecated message in C++ from class level to constructor (#1505) This prevents deprecation messages when including a header but not instantiating the class. SampleRobot was addressed by #1503. --- wpilibc/src/main/native/include/frc/GamepadBase.h | 4 ++-- wpilibc/src/main/native/include/frc/JoystickBase.h | 4 ++-- .../main/native/include/frc/livewindow/LiveWindowSendable.h | 4 ++-- .../main/native/include/frc/smartdashboard/NamedSendable.h | 6 ++++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/wpilibc/src/main/native/include/frc/GamepadBase.h b/wpilibc/src/main/native/include/frc/GamepadBase.h index fd2a75e0f6..9681c84643 100644 --- a/wpilibc/src/main/native/include/frc/GamepadBase.h +++ b/wpilibc/src/main/native/include/frc/GamepadBase.h @@ -16,9 +16,9 @@ namespace frc { /** * Gamepad Interface. */ -class WPI_DEPRECATED("Inherit directly from GenericHID instead.") GamepadBase - : public GenericHID { +class GamepadBase : public GenericHID { public: + WPI_DEPRECATED("Inherit directly from GenericHID instead.") explicit GamepadBase(int port); virtual ~GamepadBase() = default; diff --git a/wpilibc/src/main/native/include/frc/JoystickBase.h b/wpilibc/src/main/native/include/frc/JoystickBase.h index b72caf16d5..cba5a7e099 100644 --- a/wpilibc/src/main/native/include/frc/JoystickBase.h +++ b/wpilibc/src/main/native/include/frc/JoystickBase.h @@ -16,9 +16,9 @@ namespace frc { /** * Joystick Interface. */ -class WPI_DEPRECATED("Inherit directly from GenericHID instead.") JoystickBase - : public GenericHID { +class JoystickBase : public GenericHID { public: + WPI_DEPRECATED("Inherit directly from GenericHID instead.") explicit JoystickBase(int port); virtual ~JoystickBase() = default; diff --git a/wpilibc/src/main/native/include/frc/livewindow/LiveWindowSendable.h b/wpilibc/src/main/native/include/frc/livewindow/LiveWindowSendable.h index 9d89cc9a1c..172e0cb735 100644 --- a/wpilibc/src/main/native/include/frc/livewindow/LiveWindowSendable.h +++ b/wpilibc/src/main/native/include/frc/livewindow/LiveWindowSendable.h @@ -19,9 +19,9 @@ namespace frc { * Live Window Sendable is a special type of object sendable to the live window. * @deprecated Use Sendable directly instead */ -class WPI_DEPRECATED("use Sendable directly instead") LiveWindowSendable - : public Sendable { +class LiveWindowSendable : public Sendable { public: + WPI_DEPRECATED("use Sendable directly instead") LiveWindowSendable() = default; LiveWindowSendable(LiveWindowSendable&&) = default; LiveWindowSendable& operator=(LiveWindowSendable&&) = default; diff --git a/wpilibc/src/main/native/include/frc/smartdashboard/NamedSendable.h b/wpilibc/src/main/native/include/frc/smartdashboard/NamedSendable.h index 1e8ea92fd6..604d2e06cd 100644 --- a/wpilibc/src/main/native/include/frc/smartdashboard/NamedSendable.h +++ b/wpilibc/src/main/native/include/frc/smartdashboard/NamedSendable.h @@ -20,9 +20,11 @@ namespace frc { * the Smart Dashboard. * @deprecated Use Sendable directly instead */ -class WPI_DEPRECATED("use Sendable directly instead") NamedSendable - : public Sendable { +class NamedSendable : public Sendable { public: + WPI_DEPRECATED("use Sendable directly instead") + NamedSendable() = default; + void SetName(const wpi::Twine& name) override; std::string GetSubsystem() const override; void SetSubsystem(const wpi::Twine& subsystem) override;