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.
pull/2715/head
Vincent Coubard 2016-09-15 14:20:37 +01:00
parent 7669d7f8f5
commit 903afa33c4
1 changed files with 2 additions and 0 deletions

View File

@ -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);
}