Skip to content

Commit 903afa3

Browse files
committed
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.
1 parent 7669d7f commit 903afa3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

hal/common/mbed_error.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
#endif
2525

2626
WEAK void error(const char* format, ...) {
27+
#ifndef NDEBUG
2728
va_list arg;
2829
va_start(arg, format);
2930
mbed_error_vfprintf(format, arg);
3031
va_end(arg);
32+
#endif
3133
exit(1);
3234
}

0 commit comments

Comments
 (0)