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

Assertion with an optional message #1213

Open
CsatiZoltan opened this issue Aug 13, 2024 · 0 comments
Open

Assertion with an optional message #1213

CsatiZoltan opened this issue Aug 13, 2024 · 0 comments

Comments

@CsatiZoltan
Copy link
Collaborator

Feature request

Is your feature request related to a problem? Please describe.
I would like to test for preconditions and postconditions, but only when compiled in debug mode. Printing a message why something fails is useful. On the other hand, T8_ASSERT, similarly to the built-in assert, only accepts an expression, no optional message.

Describe the solution or feature you'd like
A convenience macro, e.g. T8_ASSERTF would be nice.

Describe alternatives you've considered
To achieve the same effect, we now need to use the more verbose

#if T8_ENABLE_DEBUG
   if (!condition)
      SC_ABORTF("Error message");
#endif

Alternatively, Boost has BOOST_ASSERT_MSG. There are other tricks, such as

assert(("Error message", condition));

See StackOverflow for more details.

Estimated priority

"Priority: low" Should be solved eventually

Additional context
This feature request concerns assertions, not logging. For that, functions such as t8_global_productionf already exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant