diff --git a/TESTS/mbedmicro-mbed/attributes/attributes.c b/TESTS/mbedmicro-mbed/attributes/attributes.c index 1130b43461..957441a1b9 100644 --- a/TESTS/mbedmicro-mbed/attributes/attributes.c +++ b/TESTS/mbedmicro-mbed/attributes/attributes.c @@ -137,7 +137,17 @@ int testDeprecatedUsed() { return 0; } -int testDeprecated() { - return testDeprecatedUsed(); +MBED_DEPRECATED_SINCE("v3.14", "this message should not be displayed") +void testDeprecatedSinceUnused(); +void testDeprecatedSinceUnused() { } + +MBED_DEPRECATED_SINCE("v3.14", "this message should be displayed") +int testDeprecatedSinceUsed(); +int testDeprecatedSinceUsed() { + return 0; +} + +int testDeprecated() { + return testDeprecatedUsed() + testDeprecatedSinceUsed(); } diff --git a/hal/api/FunctionPointer.h b/hal/api/FunctionPointer.h index 6299eff0e2..a5365b469f 100644 --- a/hal/api/FunctionPointer.h +++ b/hal/api/FunctionPointer.h @@ -29,12 +29,14 @@ namespace mbed { template class FunctionPointerArg1 : public Callback { public: - MBED_DEPRECATED("FunctionPointerArg1 has been replaced by Callback") + MBED_DEPRECATED_SINCE("v5.1", + "FunctionPointerArg1 has been replaced by Callback") FunctionPointerArg1(R (*function)(A1) = 0) : Callback(function) {} template - MBED_DEPRECATED("FunctionPointerArg1 has been replaced by Callback") + MBED_DEPRECATED_SINCE("v5.1", + "FunctionPointerArg1 has been replaced by Callback") FunctionPointerArg1(T *object, R (T::*member)(A1)) : Callback(object, member) {} @@ -46,12 +48,14 @@ public: template class FunctionPointerArg1 : public Callback { public: - MBED_DEPRECATED("FunctionPointer has been replaced by Callback") + MBED_DEPRECATED_SINCE("v5.1", + "FunctionPointer has been replaced by Callback") FunctionPointerArg1(R (*function)() = 0) : Callback(function) {} template - MBED_DEPRECATED("FunctionPointer has been replaced by Callback") + MBED_DEPRECATED_SINCE("v5.1", + "FunctionPointer has been replaced by Callback") FunctionPointerArg1(T *object, R (T::*member)()) : Callback(object, member) {} diff --git a/hal/api/toolchain.h b/hal/api/toolchain.h index 97184e1b7d..6373e8c6e4 100644 --- a/hal/api/toolchain.h +++ b/hal/api/toolchain.h @@ -207,7 +207,7 @@ * Mark a function declaration as deprecated, if it used then a warning will be * issued by the compiler possibly including the provided message. Note that not * all compilers are able to display the message. - * + * * @code * #include "toolchain.h" * @@ -225,6 +225,21 @@ #endif #endif +/** MBED_DEPRECATED_SINCE("version", "message string") + * Mark a function declaration as deprecated, noting that the declaration was + * deprecated on the specified version. If the function is used then a warning + * will be issued by the compiler possibly including the provided message. + * Note that not all compilers are able to display this message. + * + * @code + * #include "toolchain.h" + * + * MBED_DEPRECATED_SINCE("v5.1", "don't foo any more, bar instead") + * void foo(int arg); + * @endcode + */ +#define MBED_DEPRECATED_SINCE(D, M) MBED_DEPRECATED(M " [since " D "]") + // FILEHANDLE declaration #if defined(TOOLCHAIN_ARM) diff --git a/rtos/rtos/RtosTimer.h b/rtos/rtos/RtosTimer.h index 5f133a3058..30177f9bba 100644 --- a/rtos/rtos/RtosTimer.h +++ b/rtos/rtos/RtosTimer.h @@ -44,7 +44,8 @@ public: @param argument argument to the timer call back function. (default: NULL) @deprecated Replaced with RtosTimer(Callback, os_timer_type) */ - MBED_DEPRECATED("Replaced with RtosTimer(Callback, os_timer_type)") + MBED_DEPRECATED_SINCE("v5.1", + "Replaced with RtosTimer(Callback, os_timer_type)") RtosTimer(void (*func)(void const *argument), os_timer_type type=osTimerPeriodic, void *argument=NULL) { constructor(mbed::Callback(argument, (void (*)(void *))func), type); } diff --git a/rtos/rtos/Thread.h b/rtos/rtos/Thread.h index aab4296f23..3defa232d3 100644 --- a/rtos/rtos/Thread.h +++ b/rtos/rtos/Thread.h @@ -58,7 +58,7 @@ public: The explicit Thread::start member function should be used to spawn a thread. */ - MBED_DEPRECATED( + MBED_DEPRECATED_SINCE("v5.1", "Thread-spawning constructors hide errors and may lead to complex " "program state when a thread is declared") Thread(mbed::Callback task, @@ -83,7 +83,7 @@ public: a thread. */ template - MBED_DEPRECATED( + MBED_DEPRECATED_SINCE("v5.1", "Thread-spawning constructors hide errors and may lead to complex " "program state when a thread is declared") Thread(T *obj, void (T::*method)(), @@ -109,7 +109,7 @@ public: a thread. */ template - MBED_DEPRECATED( + MBED_DEPRECATED_SINCE("v5.1", "Thread-spawning constructors hide errors and may lead to complex " "program state when a thread is declared") Thread(T *obj, void (*method)(T *), @@ -134,7 +134,7 @@ public: The explicit Thread::start member function should be used to spawn a thread. */ - MBED_DEPRECATED( + MBED_DEPRECATED_SINCE("v5.1", "Thread-spawning constructors hide errors and may lead to complex " "program state when a thread is declared") Thread(void (*task)(void const *argument), void *argument=NULL,