File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,16 @@ extern "C" {
3838
3939#ifdef NDEBUG
4040extern void hard_assertion_failure (void );
41+
42+ /*! \brief Perform a runtime assertion always (i.e. not just when NDEBUG is undefined)
43+ * \ingroup pico_base
44+ *
45+ * This function is intended to provide useful information in debug builds like a normal asstion, but also
46+ * prevent execution proceeding in other builds
47+ *
48+ * In debug builds this is equivalent to \ref assert, however in release builds it calls \ref hard_assertion_failure
49+ * which, by default, just calls \ref panic with the string "Hard assert"
50+ */
4151static inline void hard_assert (bool condition , ...) {
4252 if (!condition )
4353 hard_assertion_failure ();
Original file line number Diff line number Diff line change 88#include "pico/runtime_init.h"
99
1010
11+ /*! \brief Handle a hard_assert condition failure
12+ * \ingroup pico_runtime
13+ *
14+ * This weak function provides the default implementation (call \ref panic with "Hard assert") for if a \ref hard_assert
15+ * condition fail in non debug builds. You can provide your own strong implementation to replace the default behavior
16+ *
17+ * \sa hard_assert
18+ */
19+
1120void __weak hard_assertion_failure (void ) {
1221 panic ("Hard assert" );
1322}
You can’t perform that action at this time.
0 commit comments