Bitcoin Core  27.99.0
P2P Digital Currency
Macros
util.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __GNUC_PREREQ(_maj, _min)   0
 
#define EXPECT(x, c)   (x)
 
#define CHECK(cond)
 Unconditional failure on condition failure. More...
 
#define CHECK_SAFE(cond)
 Check macro that does nothing in normal non-verify builds but crashes in verify builds. More...
 
#define CHECK_RETURN(cond, rvar)
 Check a condition and return on failure in non-verify builds, crash in verify builds. More...
 

Macro Definition Documentation

◆ __GNUC_PREREQ

#define __GNUC_PREREQ (   _maj,
  _min 
)    0

Definition at line 19 of file util.h.

◆ CHECK

#define CHECK (   cond)
Value:
do { \
if (EXPECT(!(cond), 0)) { \
fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, "Check condition failed: " #cond); \
abort(); \
} \
} while(0)
#define EXPECT(x, c)
Definition: util.h:26

Unconditional failure on condition failure.

Primarily used in testing harnesses.

Definition at line 35 of file util.h.

◆ CHECK_RETURN

#define CHECK_RETURN (   cond,
  rvar 
)
Value:
do { \
if (EXPECT(!(cond), 0)) { \
return rvar; \
} \
} while(0)

Check a condition and return on failure in non-verify builds, crash in verify builds.

Used for inexpensive conditions which believed to be always true in locations where a graceful exit is possible.

Definition at line 67 of file util.h.

◆ CHECK_SAFE

#define CHECK_SAFE (   cond)

Check macro that does nothing in normal non-verify builds but crashes in verify builds.

This is used to test conditions at runtime that should always be true, but are either expensive to test or in locations where returning on failure would be messy.

Definition at line 50 of file util.h.

◆ EXPECT

#define EXPECT (   x,
 
)    (x)

Definition at line 26 of file util.h.