diff --git a/platform/mbed_debug.h b/platform/mbed_debug.h index 392286a15e..761c1eb99f 100644 --- a/platform/mbed_debug.h +++ b/platform/mbed_debug.h @@ -18,49 +18,49 @@ */ #ifndef MBED_DEBUG_H #define MBED_DEBUG_H -#include "device.h" +#if DEVICE_STDIO_MESSAGES +#include +#include +#endif #ifdef __cplusplus extern "C" { #endif -#if DEVICE_STDIO_MESSAGES -#include -#include /** Output a debug message * * @param format printf-style format string, followed by variables */ static inline void debug(const char *format, ...) { +#if DEVICE_STDIO_MESSAGES && !defined(NDEBUG) va_list args; va_start(args, format); vfprintf(stderr, format, args); va_end(args); +#endif } + /** Conditionally output a debug message * - * NOTE: If the condition is constant false (!= 1) and the compiler optimization + * NOTE: If the condition is constant false (== 0) and the compiler optimization * level is greater than 0, then the whole function will be compiled away. * - * @param condition output only if condition is true (== 1) + * @param condition output only if condition is true (!= 0) * @param format printf-style format string, followed by variables */ static inline void debug_if(int condition, const char *format, ...) { - if (condition == 1) { +#if DEVICE_STDIO_MESSAGES && !defined(NDEBUG) + if (condition) { va_list args; va_start(args, format); vfprintf(stderr, format, args); va_end(args); } +#endif } -#else -static inline void debug(const char *format, ...) {} -static inline void debug_if(int condition, const char *format, ...) {} - -#endif #ifdef __cplusplus } diff --git a/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c b/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c index e23e3e54a1..206e6813c5 100755 --- a/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c +++ b/rtos/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c @@ -33,6 +33,7 @@ *---------------------------------------------------------------------------*/ #include "cmsis_os.h" +#include "mbed_error.h" /*---------------------------------------------------------------------------- @@ -244,7 +245,6 @@ void os_idle_demon (void) { /*---------------------------------------------------------------------------- * RTX Errors *---------------------------------------------------------------------------*/ -extern void error(const char* format, ...); extern osThreadId svcThreadGetId (void); void os_error (uint32_t err_code) {