Asserts module
Butano assert system.
It can be enabled or disabled by overloading the definition of BN_
Note that these asserts can be used in constexpr
contexts (is_constant_evaluated()
returns true
).
Files
- file bn_assert.h
- file bn_assert_callback_type.h
- file bn_config_assert.h
Namespaces
- namespace bn
- Main Butano namespace.
- namespace bn::assert
- Assert related functions.
Defines
- #define BN_ASSERT(condition, ...)
- #define BN_BASIC_ASSERT
- #define BN_ERROR(...)
- #define BN_CFG_ASSERT_ENABLED
- #define BN_CFG_ASSERT_SHOW_DIAGNOSTIC
- #define BN_CFG_ASSERT_BUFFER_SIZE
Define documentation
#define BN_ASSERT(condition,
...)
#include <bn_assert.h>
Checks if the specified condition is true.
If it doesn't, the execution is stopped and diagnostic information is shown on the screen.
More information can be shown by passing it by argument.
Example:
BN_ASSERT(integer > 0, "Invalid integer: ", integer);
Custom parameter types are supported by overloading bn::ostringstream::operator<<.
Example:
bn::ostringstream& operator<<(bn::ostringstream& stream, const custom_type& custom_value) { stream.append("custom_type: "); stream.append(custom_value.data); return stream; }
Note that it can be used in constexpr contexts (is_constant_evaluated() returns true
).
#define BN_BASIC_ASSERT
#include <bn_assert.h>
Checks if the specified condition is true.
If it doesn't, the execution is stopped and basic diagnostic information is shown on the screen.
More information can be shown by passing it by argument.
Example:
BN_BASIC_ASSERT(integer > 0, "Invalid integer: ", integer);
Custom parameter types are supported by overloading bn::ostringstream::operator<<.
Example:
bn::ostringstream& operator<<(bn::ostringstream& stream, const custom_type& custom_value) { stream.append("custom_type: "); stream.append(custom_value.data); return stream; }
Note that it can be used in constexpr contexts (is_constant_evaluated() returns true
).
#define BN_ERROR(...)
#include <bn_assert.h>
If this is called, the execution is stopped and diagnostic information is shown on the screen.
More information can be shown by passing it by argument.
Example:
BN_ERROR("Invalid integer: ", integer);
Custom parameter types are supported by overloading bn::ostringstream::operator<<.
Example:
bn::ostringstream& operator<<(bn::ostringstream& stream, const custom_type& custom_value) { stream.append("custom_type: "); stream.append(custom_value.data); return stream; }
Note that it can be used in constexpr contexts (is_constant_evaluated() returns true
).
#define BN_CFG_ASSERT_ENABLED
#include <bn_config_assert.h>
Specifies if asserts must be enabled or not.
#define BN_CFG_ASSERT_SHOW_DIAGNOSTIC
#include <bn_config_assert.h>
Specifies if asserts diagnostic information must be shown or not.
Disabling diagnostic information reduces ROM size.
#define BN_CFG_ASSERT_BUFFER_SIZE
#include <bn_config_assert.h>
Specifies the maximum size of the messages that can be displayed by an assert.