Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage notes for DEV_ASSERT macro #80156

Merged
merged 1 commit into from
Aug 2, 2023
Merged
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
15 changes: 13 additions & 2 deletions core/error/error_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,19 @@ void _err_flush_stdout();
((void)0)

/**
* This should be a 'free' assert for program flow and should not be needed in any releases,
* only used in dev builds.
* Note: IN MOST CASES YOU SHOULD NOT USE THIS MACRO.
* Do not use unless you understand the trade-offs.
*
* DEV macros will be compiled out in releases, they are wrapped in DEV_ENABLED.
*
* Prefer WARNINGS / ERR_FAIL macros (which fail without crashing) - ERR_FAIL should be used in most cases.
* Then CRASH_NOW_MSG macros (on rare occasions where error cannot be recovered).
*
* DEV_ASSERT should generally only be used when both of the following conditions are met:
* 1) Bottleneck code where a check in release would be too expensive.
* 2) Situations where the check would fail obviously and straight away during the maintenance of the code
* (i.e. strict conditions that should be true no matter what)
* and that can't fail for other contributors once the code is finished and merged.
*/
#ifdef DEV_ENABLED
#define DEV_ASSERT(m_cond) \
Expand Down