From 903afa33c486e3f00be40b431fb2919a6e10364b Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Thu, 15 Sep 2016 14:20:37 +0100 Subject: [PATCH] Allow the trace output by mbed error to be conditional of NDEBUG. This change avoid inclusion of printf and friends code in a binary when it is compiled with the macro NDEBUG enabled (this macro is usually enabled for production builds). Unlike assert, the error function will still crash/halt the execution of the application even if NDEBUG is enabled; the traces are just not outputed. --- hal/common/mbed_error.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hal/common/mbed_error.c b/hal/common/mbed_error.c index 3b12193422..6fc72009a7 100644 --- a/hal/common/mbed_error.c +++ b/hal/common/mbed_error.c @@ -24,9 +24,11 @@ #endif WEAK void error(const char* format, ...) { +#ifndef NDEBUG va_list arg; va_start(arg, format); mbed_error_vfprintf(format, arg); va_end(arg); +#endif exit(1); }