How to get rid of deprecated error report in Keil ?

09 Nov 2016

I am trying build ESP8266 MQTT demo within Keil uvision 4 as well as in GCC-ARM-Embedded.

According to GCC, attribute deprecated is kind of warning, but it is error in Keil and it stops me from building binary code.

mbed/platform/Callback.h(1298): error:  #1204: attribute "deprecated" does not take arguments
      MBED_DEPRECATED_SINCE("mbed-os-5.1",

I have checked the source code of toolchain.h

toolchain.h

#ifndef MBED_DEPRECATED
#if defined(__GNUC__) || defined(__clang__)
#define MBED_DEPRECATED(M) __attribute__((deprecated(M)))
#elif defined(__CC_ARM)
#define MBED_DEPRECATED(M) __attribute__((deprecated))
#else
#define MBED_DEPRECATED(M)
#endif
#endif

#define MBED_DEPRECATED_SINCE(D, M) MBED_DEPRECATED(M " [since " D "]")

The error comes come following code:

callback.h

    template <typename T>
    MBED_DEPRECATED_SINCE("mbed-os-5.1", 
        "Arguments to callback have been reordered to attach(func, arg)")
    void attach(const T *obj, R (*func)(const T*, A0)) {
        this->~Callback();
        new (this) Callback(func, obj);
    }

I changed MBED_DEPRECATED_SINCE() in one line like this:

code in one line

MBED_DEPRECATED_SINCE("mbed-os-5.1", "Arguments to callback have been reordered to attach(func, arg)")

It doesn't help at all.

new error

mbed/platform/Callback.h(1312): error:  #1204: attribute "deprecated" does not take arguments
      MBED_DEPRECATED_SINCE("mbed-os-5.1", "Arguments to callback have been reordered to attach(func, arg)")

What's wrong with that code ?

11 Nov 2016
13 Nov 2016

I have encountered the same issue.

23 Nov 2016

I strongly recommend you to migrate latest revision of Keil MDK-ARM. But, if you have any special reason to use old version of MDK-ARM, you need to modify source code as below:

toolchain.h

#ifndef MBED_DEPRECATED
#if defined(__CC_ARM) && (__ARMCC_VERSION < 5060000)
#define MBED_DEPRECATED(M) __attribute__((deprecated))
#elif defined(__GNUC__) || defined(__clang__)
#define MBED_DEPRECATED(M) __attribute__((deprecated(M)))
#elif defined(__CC_ARM)
#define MBED_DEPRECATED(M) __attribute__((deprecated))
#else
#define MBED_DEPRECATED(M)
#endif
#endif

You may also see some more compile erros in mbed_rtc_time.cpp, then you will change it to:

mbed_rtc_time.cpp

#if defined (__ICCARM__)
time_t __time32(time_t *timer)
#else
time_t std::time(time_t *timer)
#endif

{

and also...

mbed_rtc_time.cpp

clock_t std::clock() {

I hope this helps.