Skip to content

Commit

Permalink
Merge pull request #7 from Kijewski/RIOT_assert
Browse files Browse the repository at this point in the history
core: define assertion failed message in one place
  • Loading branch information
OlegHahm committed Aug 29, 2015
2 parents f604738 + 1817200 commit b3a6af6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/include/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
extern "C" {
#endif

extern const char assert_crash_message[];

/**
* @brief abort the program if assertion is false
*
Expand All @@ -41,7 +43,7 @@ extern "C" {
#ifdef NDEBUG
#define assert(ignore)((void) 0)
#else
#define assert(cond) ((cond) ? (void)0 : core_panic(PANIC_ASSERT_FAIL, "assert"))
#define assert(cond) ((cond) ? (void)0 : core_panic(PANIC_ASSERT_FAIL, assert_crash_message))
#endif

#ifdef __cplusplus
Expand Down
3 changes: 3 additions & 0 deletions core/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <string.h>
#include <stdio.h>

#include "assert.h"
#include "cpu.h"
#include "irq.h"
#include "lpm.h"
Expand All @@ -34,6 +35,8 @@
#include "ps.h"
#endif

const char assert_crash_message[] = "Failed assertion.";

/* flag preventing "recursive crash printing loop" */
static int crashed = 0;

Expand Down

0 comments on commit b3a6af6

Please sign in to comment.