Introduce CELLO_ERROR
, CELLO_REQUIRE
, CELLO_WARN
#401
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request summary
This introduces 3 function-like macros for error-reporting and logging purposes. The intention is to replace the existing
ERROR
,ASSERT
andWARNING
families of macros.Detailed Description
About
CELLO_ERROR
For the sake of motivating this change, let's focus on the
CELLO_ERROR
macro. This macro should be treated as though it is a function with the declarationThe idea is that this single macro replaces the entire exiting
ERROR
macro family. For context, those macros are used as though they have the following function signatures:Essentially,
CELLO_ERROR
makes 2 key innovations:func_name
, the name of the function that we are invoking the macro from. This is detected automatically byCELLO_ERROR
__func__
variable that is implicitly define within every function/method starting with c++ 111func_name
when they copy an error between functions or they rename a function. This change will make things completely unnecessary.Other macros
Just as
CELLO_ERROR
replaces theERROR
macro family,CELLO_REQUIRE
replaces theASSERT
macro familyCELLO_WARN
replaces theWARNING
macro familyThese other 2 macros should be treated as though they are functions with the following signatures
One important note: in the
ASSERT
macro-family, the assertion condition is always the last argument. In contrast, the assertion-condition is always the first argument ofCELLO_REQUIRE
.CELLO_REQUIRE
rather thanCELLO_ASSERT
.2Caveats
The main caveat is that these new macros will coexist alongside the old macros.
In the event that this is accepted, I think we should hold off on merging this until after we make a decision on Issue Use
fmt
C++ library? OPINIONS WANTED! #400 (to be clear, I think the review of this PR should proceed without worrying about that other issue - we may just want to coordinate things if we decide to proceed with both proposals).This is a major change or addition (that needs 2 reviewers): unknown
PR Checklist
Footnotes
where available, we prefer compiler-specific alternatives like
__PRETTY_FUNCTION__
on gcc and clang. This gives a more descriptive name (including the scope, any template specializations, and the precise function signature). ↩the other reason is to make
CELLO_REQUIRE
a little more distinct from theassert
macro introduced by<assert.h>
. The key point is that the behavior ofCELLO_REQUIRE
is completely independent of other macros. In contrast,assert
becomes a no-op when theNDEBUG
macro is defined. ↩