The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
Diff: platform/mbed_debug.h
- Revision:
- 142:4eea097334d6
- Parent:
- 128:9bcdf88f62b0
--- a/platform/mbed_debug.h Fri Apr 28 13:09:19 2017 +0100 +++ b/platform/mbed_debug.h Wed May 10 11:31:27 2017 +0100 @@ -18,49 +18,49 @@ */ #ifndef MBED_DEBUG_H #define MBED_DEBUG_H -#include "device.h" +#if DEVICE_STDIO_MESSAGES +#include <stdio.h> +#include <stdarg.h> +#endif #ifdef __cplusplus extern "C" { #endif -#if DEVICE_STDIO_MESSAGES -#include <stdio.h> -#include <stdarg.h> /** 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 }