From f64b0554995b0bd12e9f6ff837131dead7cec081 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Wed, 23 Sep 2015 23:44:54 -0700 Subject: [PATCH] Provide DEPRECATED macro as portable version of [[deprecated]]. The [[deprecated]] attribute is a C++14 feature not supported by MSVC or GCC < 4.9, but can be simulated on both of these compilers through the use of alternative (compiler-specific) attribute methods. Change-Id: I34aed5705db2407c592f7cabd5274358c48d34fe --- wpilibc/wpilibC++/include/Base.h | 22 +++++++++++---- .../wpilibC++/include/LiveWindow/LiveWindow.h | 24 ++++------------ .../include/AnalogAccelerometer.h | 4 +-- .../include/AnalogPotentiometer.h | 4 +-- wpilibc/wpilibC++Devices/include/Counter.h | 28 +++++++++---------- wpilibc/wpilibC++Devices/include/Encoder.h | 10 +++---- wpilibc/wpilibC++Devices/include/Gyro.h | 4 +-- .../wpilibC++Devices/include/Preferences.h | 4 +-- wpilibc/wpilibC++Devices/include/RobotDrive.h | 8 +++--- wpilibc/wpilibC++Devices/include/Ultrasonic.h | 8 +++--- .../src/AnalogAccelerometer.cpp | 4 +-- .../src/AnalogPotentiometer.cpp | 4 +-- wpilibc/wpilibC++Devices/src/Counter.cpp | 28 +++++++++---------- wpilibc/wpilibC++Devices/src/Encoder.cpp | 10 +++---- wpilibc/wpilibC++Devices/src/Gyro.cpp | 4 +-- wpilibc/wpilibC++Devices/src/RobotDrive.cpp | 10 +++---- wpilibc/wpilibC++Devices/src/Ultrasonic.cpp | 8 +++--- 17 files changed, 92 insertions(+), 92 deletions(-) diff --git a/wpilibc/wpilibC++/include/Base.h b/wpilibc/wpilibC++/include/Base.h index 826536817f..396eeacc61 100644 --- a/wpilibc/wpilibC++/include/Base.h +++ b/wpilibc/wpilibC++/include/Base.h @@ -26,17 +26,29 @@ ClassName(ClassName &&) = default #define noexcept throw() #endif +// [[deprecated(msg)]] is a C++14 feature not supported by MSVC or GCC < 4.9. +// We provide an equivalent warning implementation for those compilers here. +#if defined(_MSC_VER) + #define DEPRECATED(msg) __declspec(deprecated(msg)) +#elif defined(__GNUC__) + #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 8) + #define DEPRECATED(msg) [[deprecated(msg)]] + #else + #define DEPRECATED(msg) __attribute__((deprecated(msg))) + #endif +#elif __cplusplus > 201103L + #define DEPRECATED(msg) [[deprecated(msg)]] +#else + #define DEPRECATED(msg) /*nothing*/ +#endif + // A struct to use as a deleter when a std::shared_ptr must wrap a raw pointer // that is being deleted by someone else. // This should only be called in deprecated functions; using it anywhere else // will throw warnings. template struct -#if !defined(_MSC_VER) - [[deprecated]] -#else - __declspec(deprecated) -#endif +DEPRECATED("wrapping raw pointer in std::shared_ptr") NullDeleter { void operator()(T *) const noexcept {}; }; diff --git a/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h b/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h index 5d41441423..e70b82d68c 100644 --- a/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h +++ b/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h @@ -32,26 +32,18 @@ class LiveWindow { public: static LiveWindow *GetInstance(); void Run(); -#if !defined(_MSC_VER) - [[deprecated( + DEPRECATED( "Raw pointers are deprecated; pass the component using shared_ptr " - "instead.")]] -#else - __declspec(deprecated("**Raw pointers are deprecated; pass the component using shared_ptr instead**")) -#endif + "instead.") void AddSensor(const std::string &subsystem, const std::string &name, LiveWindowSendable *component); void AddSensor(const std::string &subsystem, const std::string &name, LiveWindowSendable &component); void AddSensor(const std::string &subsystem, const std::string &name, std::shared_ptr component); -#if !defined(_MSC_VER) - [[deprecated( + DEPRECATED( "Raw pointers are deprecated; pass the component using shared_ptr " - "instead.")]] -#else - __declspec(deprecated("**Raw pointers are deprecated; pass the component using shared_ptr instead**")) -#endif + "instead.") void AddActuator(const std::string &subsystem, const std::string &name, LiveWindowSendable *component); void AddActuator(const std::string &subsystem, const std::string &name, @@ -59,13 +51,9 @@ class LiveWindow { void AddActuator(const std::string &subsystem, const std::string &name, std::shared_ptr component); -#if !defined(_MSC_VER) - [[deprecated( + DEPRECATED( "Raw pointers are deprecated; pass the component using shared_ptr " - "instead.")]] -#else - __declspec(deprecated("**Raw pointers are deprecated; pass the component using shared_ptr instead**")) -#endif + "instead.") void AddSensor(std::string type, int channel, LiveWindowSendable *component); void AddActuator(std::string type, int channel, LiveWindowSendable *component); diff --git a/wpilibc/wpilibC++Devices/include/AnalogAccelerometer.h b/wpilibc/wpilibC++Devices/include/AnalogAccelerometer.h index aa18e6e308..deec3fa9d2 100644 --- a/wpilibc/wpilibC++Devices/include/AnalogAccelerometer.h +++ b/wpilibc/wpilibC++Devices/include/AnalogAccelerometer.h @@ -26,11 +26,11 @@ class AnalogAccelerometer : public SensorBase, public LiveWindowSendable { public: explicit AnalogAccelerometer(int32_t channel); - [[deprecated( + DEPRECATED( "Raw pointers are deprecated; if you just want to construct an " "AnalogAccelerometer with its own AnalogInput, then call the " "AnalogAccelerometer(int channel). If you want to keep your own copy of " - "the AnalogInput, use std::shared_ptr.")]] + "the AnalogInput, use std::shared_ptr.") explicit AnalogAccelerometer(AnalogInput *channel); explicit AnalogAccelerometer(std::shared_ptr channel); virtual ~AnalogAccelerometer() = default; diff --git a/wpilibc/wpilibC++Devices/include/AnalogPotentiometer.h b/wpilibc/wpilibC++Devices/include/AnalogPotentiometer.h index 3d27ea3dd6..37007669b6 100644 --- a/wpilibc/wpilibC++Devices/include/AnalogPotentiometer.h +++ b/wpilibc/wpilibC++Devices/include/AnalogPotentiometer.h @@ -36,11 +36,11 @@ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable { explicit AnalogPotentiometer(int channel, double fullRange = 1.0, double offset = 0.0); - [[deprecated( + DEPRECATED( "Raw pointers are deprecated; if you just want to construct an " "AnalogPotentiometer with its own AnalogInput, then call the " "AnalogPotentiometer(int channel). If you want to keep your own copy of " - "the AnalogInput, use std::shared_ptr.")]] + "the AnalogInput, use std::shared_ptr.") explicit AnalogPotentiometer(AnalogInput *input, double fullRange = 1.0, double offset = 0.0); diff --git a/wpilibc/wpilibC++Devices/include/Counter.h b/wpilibc/wpilibC++Devices/include/Counter.h index 2001ffa0b6..a93eb3c604 100644 --- a/wpilibc/wpilibC++Devices/include/Counter.h +++ b/wpilibc/wpilibC++Devices/include/Counter.h @@ -31,19 +31,19 @@ class Counter : public SensorBase, public: explicit Counter(Mode mode = kTwoPulse); explicit Counter(int32_t channel); - [[deprecated( + DEPRECATED( "Raw pointers are deprecated; if you just want to construct a Counter " "with its own DigitalSource, then call the Counter(int channel). If you " "want to keep your own copy of the DigitalSource, use " - "std::shared_ptr.")]] + "std::shared_ptr.") explicit Counter(DigitalSource *source); explicit Counter(std::shared_ptr source); - [[deprecated( - "Raw pointers are deprecated. Use pass-by-reference instead.")]] + DEPRECATED( + "Raw pointers are deprecated. Use pass-by-reference instead.") explicit Counter(AnalogTrigger *trigger); explicit Counter(const AnalogTrigger &trigger); - [[deprecated( - "Raw pointers are deprecated; prefer to use shared_ptr instead.")]] + DEPRECATED( + "Raw pointers are deprecated; prefer to use shared_ptr instead.") Counter(EncodingType encodingType, DigitalSource *upSource, DigitalSource *downSource, bool inverted); Counter(EncodingType encodingType, std::shared_ptr upSource, @@ -51,32 +51,32 @@ class Counter : public SensorBase, virtual ~Counter(); void SetUpSource(int32_t channel); - [[deprecated( + DEPRECATED( "Raw pointers are deprecated; prefer to call either SetUpSource(int) or " - "SetUpSource(shared_ptr).")]] + "SetUpSource(shared_ptr).") void SetUpSource(AnalogTrigger *analogTrigger, AnalogTriggerType triggerType); void SetUpSource(std::shared_ptr analogTrigger, AnalogTriggerType triggerType); - [[deprecated("Raw pointers are deprecated. Use std::shared_ptr instead.")]] + DEPRECATED("Raw pointers are deprecated. Use std::shared_ptr instead.") void SetUpSource(DigitalSource *source); void SetUpSource(std::shared_ptr source); - [[deprecated("References are deprecated. Use std::shared_ptr instead.")]] + DEPRECATED("References are deprecated. Use std::shared_ptr instead.") void SetUpSource(DigitalSource &source); void SetUpSourceEdge(bool risingEdge, bool fallingEdge); void ClearUpSource(); void SetDownSource(int32_t channel); - [[deprecated( + DEPRECATED( "Raw pointers are deprecated; prefer to call either SetDownSource(int) " - "or SetDownSource(shared_ptr).")]] + "or SetDownSource(shared_ptr).") void SetDownSource(AnalogTrigger *analogTrigger, AnalogTriggerType triggerType); void SetDownSource(std::shared_ptr analogTrigger, AnalogTriggerType triggerType); - [[deprecated("Raw pointers are deprecated. Use std::shared_ptr instead.")]] + DEPRECATED("Raw pointers are deprecated. Use std::shared_ptr instead.") void SetDownSource(DigitalSource *source); void SetDownSource(std::shared_ptr source); - [[deprecated("References are deprecated. Use std::shared_ptr instead.")]] + DEPRECATED("References are deprecated. Use std::shared_ptr instead.") void SetDownSource(DigitalSource &source); void SetDownSourceEdge(bool risingEdge, bool fallingEdge); void ClearDownSource(); diff --git a/wpilibc/wpilibC++Devices/include/Encoder.h b/wpilibc/wpilibC++Devices/include/Encoder.h index 7fae4c9fa0..c8ee1dd102 100644 --- a/wpilibc/wpilibC++Devices/include/Encoder.h +++ b/wpilibc/wpilibC++Devices/include/Encoder.h @@ -52,16 +52,16 @@ class Encoder : public SensorBase, Encoder(std::shared_ptr aSource, std::shared_ptr bSource, bool reverseDirection = false, EncodingType encodingType = k4X); - [[deprecated( + DEPRECATED( "Raw pointers are deprecated; if you wish to construct your own copy of " "the DigitalSource and pass it to the constructor, use an " - "std::shared_ptr instead.")]] + "std::shared_ptr instead.") Encoder(DigitalSource *aSource, DigitalSource *bSource, bool reverseDirection = false, EncodingType encodingType = k4X); - [[deprecated( + DEPRECATED( "References are deprecated; if you wish to construct your own copy of " "the DigitalSource and pass it to the constructor, use an " - "std::shared_ptr instead.")]] + "std::shared_ptr instead.") Encoder(DigitalSource &aSource, DigitalSource &bSource, bool reverseDirection = false, EncodingType encodingType = k4X); virtual ~Encoder(); @@ -86,7 +86,7 @@ class Encoder : public SensorBase, double PIDGet() override; void SetIndexSource(uint32_t channel, IndexingType type = kResetOnRisingEdge); - [[deprecated("Raw pointers are deprecated; use references instead.")]] + DEPRECATED("Raw pointers are deprecated; use references instead.") void SetIndexSource(DigitalSource *source, IndexingType type = kResetOnRisingEdge); void SetIndexSource(const DigitalSource &source, diff --git a/wpilibc/wpilibC++Devices/include/Gyro.h b/wpilibc/wpilibC++Devices/include/Gyro.h index 46eb128b68..0a8c9f2f66 100644 --- a/wpilibc/wpilibC++Devices/include/Gyro.h +++ b/wpilibc/wpilibC++Devices/include/Gyro.h @@ -39,9 +39,9 @@ class Gyro : public SensorBase, public PIDSource, public LiveWindowSendable { static constexpr float kDefaultVoltsPerDegreePerSecond = 0.007; explicit Gyro(int32_t channel); - [[deprecated( + DEPRECATED( "Raw pointers are deprecated; consider calling the Gyro constructor with " - "a channel number or passing a shared_ptr instead.")]] + "a channel number or passing a shared_ptr instead.") explicit Gyro(AnalogInput *channel); explicit Gyro(std::shared_ptr channel); virtual ~Gyro() = default; diff --git a/wpilibc/wpilibC++Devices/include/Preferences.h b/wpilibc/wpilibC++Devices/include/Preferences.h index 525ae210ce..54371acf1a 100644 --- a/wpilibc/wpilibC++Devices/include/Preferences.h +++ b/wpilibc/wpilibC++Devices/include/Preferences.h @@ -48,8 +48,8 @@ class Preferences : public ErrorBase { void PutFloat(llvm::StringRef key, float value); void PutBoolean(llvm::StringRef key, bool value); void PutLong(llvm::StringRef key, int64_t value); - [[deprecated( - "Saving is now automatically performed by the NetworkTables server.")]] + DEPRECATED( + "Saving is now automatically performed by the NetworkTables server.") void Save(); bool ContainsKey(llvm::StringRef key); void Remove(llvm::StringRef key); diff --git a/wpilibc/wpilibC++Devices/include/RobotDrive.h b/wpilibc/wpilibC++Devices/include/RobotDrive.h index 697269c537..eb42f42f63 100644 --- a/wpilibc/wpilibC++Devices/include/RobotDrive.h +++ b/wpilibc/wpilibC++Devices/include/RobotDrive.h @@ -44,16 +44,16 @@ class RobotDrive : public MotorSafety, public ErrorBase { RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel); RobotDrive(uint32_t frontLeftMotorChannel, uint32_t rearLeftMotorChannel, uint32_t frontRightMotorChannel, uint32_t rearRightMotorChannel); - [[deprecated("Raw pointers are deprecated; use shared_ptr instead.")]] + DEPRECATED("Raw pointers are deprecated; use shared_ptr instead.") RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor); - [[deprecated("References are deprecated; use shared_ptr instead.")]] + DEPRECATED("References are deprecated; use shared_ptr instead.") RobotDrive(SpeedController &leftMotor, SpeedController &rightMotor); RobotDrive(std::shared_ptr leftMotor, std::shared_ptr rightMotor); - [[deprecated("Raw pointers are deprecated; use shared_ptr instead.")]] + DEPRECATED("Raw pointers are deprecated; use shared_ptr instead.") RobotDrive(SpeedController *frontLeftMotor, SpeedController *rearLeftMotor, SpeedController *frontRightMotor, SpeedController *rearRightMotor); - [[deprecated("References are deprecated; use shared_ptr instead.")]] + DEPRECATED("References are deprecated; use shared_ptr instead.") RobotDrive(SpeedController &frontLeftMotor, SpeedController &rearLeftMotor, SpeedController &frontRightMotor, SpeedController &rearRightMotor); RobotDrive(std::shared_ptr frontLeftMotor, diff --git a/wpilibc/wpilibC++Devices/include/Ultrasonic.h b/wpilibc/wpilibC++Devices/include/Ultrasonic.h index 59f28fdcd0..5f9df650ff 100644 --- a/wpilibc/wpilibC++Devices/include/Ultrasonic.h +++ b/wpilibc/wpilibC++Devices/include/Ultrasonic.h @@ -42,15 +42,15 @@ class Ultrasonic : public SensorBase, public: enum DistanceUnit { kInches = 0, kMilliMeters = 1 }; - [[deprecated( + DEPRECATED( "Raw pointers are deprecated; prefer either specifying the channel " - "numbers as integers or passing shared_ptrs.")]] + "numbers as integers or passing shared_ptrs.") Ultrasonic(DigitalOutput *pingChannel, DigitalInput *echoChannel, DistanceUnit units = kInches); - [[deprecated( + DEPRECATED( "References are deprecated; prefer either specifying the channel numbers " - "as integers or passing shared_ptrs.")]] + "as integers or passing shared_ptrs.") Ultrasonic(DigitalOutput &pingChannel, DigitalInput &echoChannel, DistanceUnit units = kInches); diff --git a/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp b/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp index d5567f3b2e..93e3d02f61 100644 --- a/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp +++ b/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp @@ -39,11 +39,11 @@ AnalogAccelerometer::AnalogAccelerometer(int32_t channel) { * @param channel The existing AnalogInput object for the analog input the * accelerometer is connected to */ -[[deprecated( +DEPRECATED( "Raw pointers are deprecated; if you just want to construct an " "AnalogAccelerometer with its own AnalogInput, then call the " "AnalogAccelerometer(int channel). If you want to keep your own copy of " - "the AnalogInput, use std::shared_ptr.")]] + "the AnalogInput, use std::shared_ptr.") AnalogAccelerometer::AnalogAccelerometer(AnalogInput *channel) : m_analogInput(channel, NullDeleter()) { if (channel == nullptr) { diff --git a/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp b/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp index a944312ec1..b5c703f50e 100644 --- a/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp +++ b/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp @@ -25,11 +25,11 @@ AnalogPotentiometer::AnalogPotentiometer(int channel, double fullRange, * @param offset The angular value (in desired units) representing the angular * output at 0V. */ -[[deprecated( +DEPRECATED( "Raw pointers are deprecated; if you just want to construct an " "AnalogPotentiometer with its own AnalogInput, then call the " "AnalogPotentiometer(int channel). If you want to keep your own copy of " - "the AnalogInput, use std::shared_ptr.")]] + "the AnalogInput, use std::shared_ptr.") AnalogPotentiometer::AnalogPotentiometer(AnalogInput *input, double fullRange, double offset) : m_analog_input(input, NullDeleter()), diff --git a/wpilibc/wpilibC++Devices/src/Counter.cpp b/wpilibc/wpilibC++Devices/src/Counter.cpp index cfbacb93e8..6532b67595 100644 --- a/wpilibc/wpilibC++Devices/src/Counter.cpp +++ b/wpilibc/wpilibC++Devices/src/Counter.cpp @@ -46,10 +46,10 @@ Counter::Counter(Mode mode) { * @param source A pointer to the existing DigitalSource object. It will be set * as the Up Source. */ -[[deprecated( +DEPRECATED( "Raw pointers are deprecated; if you just want to construct a Counter with " "its own DigitalSource, then call the Counter(int channel). If you want to " - "keep your own copy of the DigitalSource, use std::shared_ptr.")]] + "keep your own copy of the DigitalSource, use std::shared_ptr.") Counter::Counter(DigitalSource *source) : Counter() { SetUpSource(source); ClearDownSource(); @@ -93,8 +93,8 @@ Counter::Counter(int32_t channel) : Counter() { * The counter will start counting immediately. * @param trigger The pointer to the existing AnalogTrigger object. */ -[[deprecated( - "Raw pointers are deprecated. Use pass-by-reference instead.")]] +DEPRECATED( + "Raw pointers are deprecated. Use pass-by-reference instead.") Counter::Counter(AnalogTrigger *trigger) : Counter() { SetUpSource(trigger->CreateOutput(kState)); ClearDownSource(); @@ -121,8 +121,8 @@ Counter::Counter(const AnalogTrigger &trigger) : Counter() { * @param downSource The pointer to the DigitalSource to set as the down source * @param inverted True to invert the output (reverse the direction) */ -[[deprecated( - "Raw pointers are deprecated; prefer to use shared_ptr instead.")]] +DEPRECATED( + "Raw pointers are deprecated; prefer to use shared_ptr instead.") Counter::Counter(EncodingType encodingType, DigitalSource *upSource, DigitalSource *downSource, bool inverted) : Counter(encodingType, @@ -193,9 +193,9 @@ void Counter::SetUpSource(int32_t channel) { * @param analogTrigger The analog trigger object that is used for the Up Source * @param triggerType The analog trigger output that will trigger the counter. */ -[[deprecated( +DEPRECATED( "Raw pointers are deprecated; prefer to call either SetUpSource(int) or " - "SetUpSource(shared_ptr).")]] + "SetUpSource(shared_ptr).") void Counter::SetUpSource(AnalogTrigger *analogTrigger, AnalogTriggerType triggerType) { SetUpSource(std::shared_ptr(analogTrigger, @@ -232,7 +232,7 @@ void Counter::SetUpSource(std::shared_ptr source) { } } -[[deprecated("Raw pointers are deprecated. Use std::shared_ptr instead.")]] +DEPRECATED("Raw pointers are deprecated. Use std::shared_ptr instead.") void Counter::SetUpSource(DigitalSource *source) { SetUpSource( std::shared_ptr(source, NullDeleter())); @@ -243,7 +243,7 @@ void Counter::SetUpSource(DigitalSource *source) { * Set the up counting DigitalSource. * @param source Reference to the DigitalSource object to set as the up source */ -[[deprecated("References are deprecated. Use std::shared_ptr instead.")]] +DEPRECATED("References are deprecated. Use std::shared_ptr instead.") void Counter::SetUpSource(DigitalSource &source) { SetUpSource( std::shared_ptr(&source, NullDeleter())); @@ -294,9 +294,9 @@ void Counter::SetDownSource(int32_t channel) { * Source * @param triggerType The analog trigger output that will trigger the counter. */ -[[deprecated( +DEPRECATED( "Raw pointers are deprecated; prefer to call either SetUpSource(int) or " - "SetUpSource(shared_ptr).")]] + "SetUpSource(shared_ptr).") void Counter::SetDownSource(AnalogTrigger *analogTrigger, AnalogTriggerType triggerType) { SetDownSource(std::shared_ptr(analogTrigger, NullDeleter()), triggerType); @@ -332,7 +332,7 @@ void Counter::SetDownSource(std::shared_ptr source) { } } -[[deprecated("Raw pointers are deprecated. Use std::shared_ptr instead.")]] +DEPRECATED("Raw pointers are deprecated. Use std::shared_ptr instead.") void Counter::SetDownSource(DigitalSource *source) { SetDownSource(std::shared_ptr(source, NullDeleter())); } @@ -342,7 +342,7 @@ void Counter::SetDownSource(DigitalSource *source) { * Set the down counting DigitalSource. * @param source Reference to the DigitalSource object to set as the down source */ -[[deprecated("References are deprecated. Use std::shared_ptr instead.")]] +DEPRECATED("References are deprecated. Use std::shared_ptr instead.") void Counter::SetDownSource(DigitalSource &source) { SetDownSource(std::shared_ptr(&source, NullDeleter())); } diff --git a/wpilibc/wpilibC++Devices/src/Encoder.cpp b/wpilibc/wpilibC++Devices/src/Encoder.cpp index d999e19088..355bb44c66 100644 --- a/wpilibc/wpilibC++Devices/src/Encoder.cpp +++ b/wpilibc/wpilibC++Devices/src/Encoder.cpp @@ -125,10 +125,10 @@ Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection, * match the spec'd count * or be double (2x) the spec'd count. */ -[[deprecated( +DEPRECATED( "Raw pointers are deprecated; if you wish to construct your own copy of " "the DigitalSource and pass it to the constructor, use an std::shared_ptr " - "instead.")]] + "instead.") Encoder::Encoder(DigitalSource *aSource, DigitalSource *bSource, bool reverseDirection, EncodingType encodingType) : m_aSource(aSource, NullDeleter()), @@ -174,10 +174,10 @@ Encoder::Encoder(std::shared_ptr aSource, * match the spec'd count * or be double (2x) the spec'd count. */ -[[deprecated( +DEPRECATED( "References are deprecated; if you wish to construct your own copy of " "the DigitalSource and pass it to the constructor, use an std::shared_ptr " - "instead.")]] + "instead.") Encoder::Encoder(DigitalSource &aSource, DigitalSource &bSource, bool reverseDirection, EncodingType encodingType) : m_aSource(&aSource, NullDeleter()), @@ -517,7 +517,7 @@ void Encoder::SetIndexSource(uint32_t channel, Encoder::IndexingType type) { * @param channel A digital source to set as the encoder index * @param type The state that will cause the encoder to reset */ -[[deprecated("Raw pointers are dperecated; use references instead.")]] +DEPRECATED("Raw pointers are dperecated; use references instead.") void Encoder::SetIndexSource(DigitalSource *source, Encoder::IndexingType type) { SetIndexSource(*source, type); diff --git a/wpilibc/wpilibC++Devices/src/Gyro.cpp b/wpilibc/wpilibC++Devices/src/Gyro.cpp index 291a4ce8dd..eb33e5dc17 100644 --- a/wpilibc/wpilibC++Devices/src/Gyro.cpp +++ b/wpilibc/wpilibC++Devices/src/Gyro.cpp @@ -88,9 +88,9 @@ Gyro::Gyro(int32_t channel) { * @param channel A pointer to the AnalogInput object that the gyro is connected * to. */ -[[deprecated( +DEPRECATED( "Raw pointers are deprecated; consider calling the Gyro constructor with " - "a channel number or passing a shared_ptr instead.")]] + "a channel number or passing a shared_ptr instead.") Gyro::Gyro(AnalogInput *channel) : Gyro(std::shared_ptr(channel, NullDeleter())) {} diff --git a/wpilibc/wpilibC++Devices/src/RobotDrive.cpp b/wpilibc/wpilibC++Devices/src/RobotDrive.cpp index 782344b25a..8ca9c27789 100644 --- a/wpilibc/wpilibC++Devices/src/RobotDrive.cpp +++ b/wpilibc/wpilibC++Devices/src/RobotDrive.cpp @@ -21,7 +21,7 @@ const int32_t RobotDrive::kMaxNumberOfMotors; -[[deprecated]] +DEPRECATED("making shared pointer from raw pointer") static auto make_shared_nodelete(SpeedController *ptr) { return std::shared_ptr(ptr, NullDeleter()); } @@ -98,7 +98,7 @@ RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor, * @param leftMotor The left SpeedController object used to drive the robot. * @param rightMotor the right SpeedController object used to drive the robot. */ -[[deprecated("Raw pointers are deprecated; use shared_ptr instead.")]] +DEPRECATED("Raw pointers are deprecated; use shared_ptr instead.") RobotDrive::RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor) { InitRobotDrive(); @@ -112,7 +112,7 @@ RobotDrive::RobotDrive(SpeedController *leftMotor, } //TODO: Change to rvalue references & move syntax. -[[deprecated("References are deprecated; use shared_ptr instead.")]] +DEPRECATED("References are deprecated; use shared_ptr instead.") RobotDrive::RobotDrive(SpeedController &leftMotor, SpeedController &rightMotor) { InitRobotDrive(); @@ -145,7 +145,7 @@ RobotDrive::RobotDrive(std::shared_ptr leftMotor, * @param frontRightMotor The front right SpeedController object used to drive * the robot. */ -[[deprecated("Raw pointers are deprecated; use shared_ptr instead.")]] +DEPRECATED("Raw pointers are deprecated; use shared_ptr instead.") RobotDrive::RobotDrive(SpeedController *frontLeftMotor, SpeedController *rearLeftMotor, SpeedController *frontRightMotor, @@ -162,7 +162,7 @@ RobotDrive::RobotDrive(SpeedController *frontLeftMotor, m_rearRightMotor = make_shared_nodelete(rearRightMotor); } -[[deprecated("References are deprecated; use shared_ptr instead.")]] +DEPRECATED("References are deprecated; use shared_ptr instead.") RobotDrive::RobotDrive(SpeedController &frontLeftMotor, SpeedController &rearLeftMotor, SpeedController &frontRightMotor, diff --git a/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp b/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp index 5ddf0f645b..c7bfa24934 100644 --- a/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp +++ b/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp @@ -116,9 +116,9 @@ Ultrasonic::Ultrasonic(uint32_t pingChannel, uint32_t echoChannel, * determine the range. * @param units The units returned in either kInches or kMilliMeters */ -[[deprecated( +DEPRECATED( "Raw pointers are deprecated; prefer either specifying the channel numbers " - "as integers or passing shared_ptrs.")]] + "as integers or passing shared_ptrs.") Ultrasonic::Ultrasonic(DigitalOutput *pingChannel, DigitalInput *echoChannel, DistanceUnit units) : m_pingChannel(pingChannel, NullDeleter()), @@ -142,9 +142,9 @@ Ultrasonic::Ultrasonic(DigitalOutput *pingChannel, DigitalInput *echoChannel, * determine the range. * @param units The units returned in either kInches or kMilliMeters */ -[[deprecated( +DEPRECATED( "References are deprecated; prefer either specifying the channel numbers " - "as integers or passing shared_ptrs.")]] + "as integers or passing shared_ptrs.") Ultrasonic::Ultrasonic(DigitalOutput &pingChannel, DigitalInput &echoChannel, DistanceUnit units) : m_pingChannel(&pingChannel, NullDeleter()),