|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
Utility macros for EBGeometry. More...


Go to the source code of this file.
Macros | |
| #define | EBGEOMETRY_REQUIRE(cond, ...) |
| Always-on check of user input and one-time host setup. | |
| #define | EBGEOMETRY_EXPECT(cond) ((void)0) |
| Runtime precondition assertion for EBGeometry. | |
Utility macros for EBGeometry.
| #define EBGEOMETRY_EXPECT | ( | cond | ) | ((void)0) |
Runtime precondition assertion for EBGeometry.
When EBGEOMETRY_ENABLE_ASSERTIONS is defined (e.g. via -DEBGEOMETRY_ENABLE_ASSERTIONS on the compiler command line, in CXXFLAGS for GNU Make, or via CMake's target_compile_definitions), this macro evaluates cond and, if it is false, prints a diagnostic message to stderr and calls std::abort().
When EBGEOMETRY_ENABLE_ASSERTIONS is not defined the macro expands to ((void)0): cond is not evaluated at all, so an assertion costs exactly nothing in release. A variable computed solely to be asserted is then unused and must be marked [[maybe_unused]] at its declaration. On a device (CUDA/HIP) compilation pass with assertions enabled the macro prints the failing expression with the device printf and traps, instead of std::fprintf / std::abort. Unlike assert(), this does not depend on NDEBUG, which Release configurations define.
| cond | Boolean-convertible expression to test. |
| #define EBGEOMETRY_REQUIRE | ( | cond, | |
| ... | |||
| ) |
Always-on check of user input and one-time host setup.
Evaluates cond in every build, whether or not EBGEOMETRY_ENABLE_ASSERTIONS is defined. If it is false, prints "EBGeometry::" followed by the formatted message, the failed condition, the file and the line to stderr, and calls std::abort().
The library uses two kinds of check:
EBGEOMETRY_EXPECT for internal invariants, including on hot paths such as a signed-distance query. It compiles to nothing unless assertions are enabled.EBGEOMETRY_REQUIRE for what a caller controls – constructor arguments, sizes and counts, memory resources – checked once, outside any query loop, where a Release build would otherwise continue into a wrong answer or undefined behavior. Its cost is a few comparisons per object built.The file readers do not abort on a bad file: they throw EBGeometry::Parser::ParseError.
The message is a printf format string literal, starting with the class or function that checks, followed by its arguments:
On a device compilation pass (CUDA/HIP) the macro prints only the failed condition, with the device printf, and traps.
| cond | Boolean-convertible expression to test. Always evaluated. |
| ... | A printf format string literal, then its arguments. |