🔖 prelude
Useful C header files
Loading...
Searching...
No Matches
hint.h File Reference

Compiler hints for performance. More...

Go to the source code of this file.

Macros

#define unreachable()
 Hint indicating unreachable code.
#define assume(COND)
 Hint indicating a condition must be true.

Detailed Description

Compiler hints for performance.

Macro Definition Documentation

◆ assume

#define assume ( COND)

Hint indicating a condition must be true.

The compiler may use the knowledge that COND must be true to make additional optimizations.

Parameters
CONDA condition to assume to be true.
Note
This macro is elided when NDEBUG is defined.
Warning
Depending on your compiler, COND may or may not be evaluated at runtime. Avoid passing in conditional expressions that have side effects.
See also
C++23 [[assume()]]
GCC [[gnu::assume()]]
Clang __builtin_assume()
MSVC __assume()

◆ unreachable

#define unreachable ( )

Hint indicating unreachable code.

The compiler may use the knowledge that certain code paths are unreachable to make additional optimizations.

See also
C23 unreachable()
C++23 std::unreachable()
GCC __builtin_unreachable()
Clang __builtin_unreachable()
MSVC __assume(0)