Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/common/pico_base_headers/include/pico/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ extern "C" {

#ifdef NDEBUG
extern void hard_assertion_failure(void);

/*! \brief Perform a runtime assertion always (i.e. not just when NDEBUG is undefined)
* \ingroup pico_base
*
* This function is intended to provide useful information in debug builds like a normal assertion, but also
* prevent execution proceeding in other builds
*
* In debug builds this is equivalent to \ref assert, however in release builds it calls \ref hard_assertion_failure
* which, by default, just calls \ref panic with the string "Hard assert"
*/
static inline void hard_assert(bool condition, ...) {
if (!condition)
hard_assertion_failure();
Expand Down
9 changes: 9 additions & 0 deletions src/rp2_common/pico_runtime/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
#include "pico/runtime_init.h"


/*! \brief Handle a hard_assert condition failure
* \ingroup pico_runtime
*
* This weak function provides the default implementation (call \ref panic with "Hard assert") for if a \ref hard_assert
* condition fail in non debug builds. You can provide your own strong implementation to replace the default behavior
*
* \sa hard_assert
*/

void __weak hard_assertion_failure(void) {
panic("Hard assert");
}
Expand Down
Loading