Skip to content

Commit 8568c9e

Browse files
authored
Merge pull request #2394 from geky/deprecated-until
Add more well-defined garuntees on deprecation notices in mbed
2 parents 77e8717 + 0f516aa commit 8568c9e

File tree

5 files changed

+41
-11
lines changed

5 files changed

+41
-11
lines changed

TESTS/mbedmicro-mbed/attributes/attributes.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,17 @@ int testDeprecatedUsed() {
137137
return 0;
138138
}
139139

140+
MBED_DEPRECATED_SINCE("v3.14", "this message should not be displayed")
141+
void testDeprecatedSinceUnused();
142+
void testDeprecatedSinceUnused() { }
143+
144+
MBED_DEPRECATED_SINCE("v3.14", "this message should be displayed")
145+
int testDeprecatedSinceUsed();
146+
int testDeprecatedSinceUsed() {
147+
return 0;
148+
}
149+
140150
int testDeprecated() {
141-
return testDeprecatedUsed();
151+
return testDeprecatedUsed() + testDeprecatedSinceUsed();
142152
}
143153

hal/api/FunctionPointer.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ namespace mbed {
2929
template <typename R, typename A1>
3030
class FunctionPointerArg1 : public Callback<R(A1)> {
3131
public:
32-
MBED_DEPRECATED("FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
32+
MBED_DEPRECATED_SINCE("v5.1",
33+
"FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
3334
FunctionPointerArg1(R (*function)(A1) = 0)
3435
: Callback<R(A1)>(function) {}
3536

3637
template<typename T>
37-
MBED_DEPRECATED("FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
38+
MBED_DEPRECATED_SINCE("v5.1",
39+
"FunctionPointerArg1<R, A> has been replaced by Callback<R(A)>")
3840
FunctionPointerArg1(T *object, R (T::*member)(A1))
3941
: Callback<R(A1)>(object, member) {}
4042

@@ -46,12 +48,14 @@ class FunctionPointerArg1 : public Callback<R(A1)> {
4648
template <typename R>
4749
class FunctionPointerArg1<R, void> : public Callback<R()> {
4850
public:
49-
MBED_DEPRECATED("FunctionPointer has been replaced by Callback<void()>")
51+
MBED_DEPRECATED_SINCE("v5.1",
52+
"FunctionPointer has been replaced by Callback<void()>")
5053
FunctionPointerArg1(R (*function)() = 0)
5154
: Callback<R()>(function) {}
5255

5356
template<typename T>
54-
MBED_DEPRECATED("FunctionPointer has been replaced by Callback<void()>")
57+
MBED_DEPRECATED_SINCE("v5.1",
58+
"FunctionPointer has been replaced by Callback<void()>")
5559
FunctionPointerArg1(T *object, R (T::*member)())
5660
: Callback<R()>(object, member) {}
5761

hal/api/toolchain.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
* Mark a function declaration as deprecated, if it used then a warning will be
208208
* issued by the compiler possibly including the provided message. Note that not
209209
* all compilers are able to display the message.
210-
*
210+
*
211211
* @code
212212
* #include "toolchain.h"
213213
*
@@ -225,6 +225,21 @@
225225
#endif
226226
#endif
227227

228+
/** MBED_DEPRECATED_SINCE("version", "message string")
229+
* Mark a function declaration as deprecated, noting that the declaration was
230+
* deprecated on the specified version. If the function is used then a warning
231+
* will be issued by the compiler possibly including the provided message.
232+
* Note that not all compilers are able to display this message.
233+
*
234+
* @code
235+
* #include "toolchain.h"
236+
*
237+
* MBED_DEPRECATED_SINCE("v5.1", "don't foo any more, bar instead")
238+
* void foo(int arg);
239+
* @endcode
240+
*/
241+
#define MBED_DEPRECATED_SINCE(D, M) MBED_DEPRECATED(M " [since " D "]")
242+
228243

229244
// FILEHANDLE declaration
230245
#if defined(TOOLCHAIN_ARM)

rtos/rtos/RtosTimer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class RtosTimer {
4444
@param argument argument to the timer call back function. (default: NULL)
4545
@deprecated Replaced with RtosTimer(Callback<void()>, os_timer_type)
4646
*/
47-
MBED_DEPRECATED("Replaced with RtosTimer(Callback<void()>, os_timer_type)")
47+
MBED_DEPRECATED_SINCE("v5.1",
48+
"Replaced with RtosTimer(Callback<void()>, os_timer_type)")
4849
RtosTimer(void (*func)(void const *argument), os_timer_type type=osTimerPeriodic, void *argument=NULL) {
4950
constructor(mbed::Callback<void()>(argument, (void (*)(void *))func), type);
5051
}

rtos/rtos/Thread.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Thread {
5858
The explicit Thread::start member function should be used to spawn
5959
a thread.
6060
*/
61-
MBED_DEPRECATED(
61+
MBED_DEPRECATED_SINCE("v5.1",
6262
"Thread-spawning constructors hide errors and may lead to complex "
6363
"program state when a thread is declared")
6464
Thread(mbed::Callback<void()> task,
@@ -83,7 +83,7 @@ class Thread {
8383
a thread.
8484
*/
8585
template <typename T>
86-
MBED_DEPRECATED(
86+
MBED_DEPRECATED_SINCE("v5.1",
8787
"Thread-spawning constructors hide errors and may lead to complex "
8888
"program state when a thread is declared")
8989
Thread(T *obj, void (T::*method)(),
@@ -109,7 +109,7 @@ class Thread {
109109
a thread.
110110
*/
111111
template <typename T>
112-
MBED_DEPRECATED(
112+
MBED_DEPRECATED_SINCE("v5.1",
113113
"Thread-spawning constructors hide errors and may lead to complex "
114114
"program state when a thread is declared")
115115
Thread(T *obj, void (*method)(T *),
@@ -134,7 +134,7 @@ class Thread {
134134
The explicit Thread::start member function should be used to spawn
135135
a thread.
136136
*/
137-
MBED_DEPRECATED(
137+
MBED_DEPRECATED_SINCE("v5.1",
138138
"Thread-spawning constructors hide errors and may lead to complex "
139139
"program state when a thread is declared")
140140
Thread(void (*task)(void const *argument), void *argument=NULL,

0 commit comments

Comments
 (0)