[mbed] Modified MBED_ASSERT to use error()

Modified mbed_assert_internal() to call error() with the assertation
message instead of fprintf() followed by mbed_die(). This allows
assertation failures to be caught by custom error() functions that
replace the default weak definition.
pull/1240/head
neilt6 2015-07-13 10:20:11 -06:00
parent 3a12b5f998
commit 8d81cb49e1
2 changed files with 3 additions and 14 deletions

View File

@ -23,8 +23,7 @@ extern "C" {
/** Internal mbed assert function which is invoked when MBED_ASSERT macro failes. /** Internal mbed assert function which is invoked when MBED_ASSERT macro failes.
* This function is active only if NDEBUG is not defined prior to including this * This function is active only if NDEBUG is not defined prior to including this
* assert header file. * assert header file.
* In case of MBED_ASSERT failing condition, the assertation message is printed * In case of MBED_ASSERT failing condition, error() is called with the assertation message.
* to stderr and mbed_die() is called.
* @param expr Expresion to be checked. * @param expr Expresion to be checked.
* @param file File where assertation failed. * @param file File where assertation failed.
* @param line Failing assertation line number. * @param line Failing assertation line number.

View File

@ -14,19 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
#include "mbed_assert.h" #include "mbed_assert.h"
#include "device.h" #include "mbed_error.h"
#if DEVICE_STDIO_MESSAGES
#include <stdio.h>
#endif
#include <stdlib.h>
#include "mbed_interface.h"
void mbed_assert_internal(const char *expr, const char *file, int line) void mbed_assert_internal(const char *expr, const char *file, int line)
{ {
#if DEVICE_STDIO_MESSAGES error("mbed assertation failed: %s, file: %s, line %d \n", expr, file, line);
fprintf(stderr, "mbed assertation failed: %s, file: %s, line %d \n", expr, file, line);
#endif
mbed_die();
} }