ic-macros  0.1.5
assert_constant.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IC_ASSERT_CONSTANT(expr)    IC_BUILD_ASSERT(__builtin_constant_p(expr), #expr " is not a compile-time constant.")
 Assert that the expression is a compile-time constant. More...
 
#define IC_REQUIRE_CONSTANT(expr)
 Require that the expression is a compile-time constant before returning it unchanged. More...
 
#define IC_ASSERT_NOT_CONSTANT(expr)    IC_BUILD_ASSERT(!__builtin_constant_p(expr), #expr " is a compile-time constant.")
 Assert that the expression is not a compile-time constant. More...
 
#define IC_REQUIRE_NOT_CONSTANT(expr)
 Require that the expression is not a compile-time constant before returning it unchanged. More...
 

Macro Definition Documentation

◆ IC_ASSERT_CONSTANT

#define IC_ASSERT_CONSTANT (   expr)     IC_BUILD_ASSERT(__builtin_constant_p(expr), #expr " is not a compile-time constant.")

Assert that the expression is a compile-time constant.

Raises a compile error if the expression is not constant.

Parameters
exprexpression

Definition at line 22 of file assert_constant.h.

◆ IC_ASSERT_NOT_CONSTANT

#define IC_ASSERT_NOT_CONSTANT (   expr)     IC_BUILD_ASSERT(!__builtin_constant_p(expr), #expr " is a compile-time constant.")

Assert that the expression is not a compile-time constant.

Raises a compile error if the expression is constant.

Parameters
exprexpression

Definition at line 42 of file assert_constant.h.

◆ IC_REQUIRE_CONSTANT

#define IC_REQUIRE_CONSTANT (   expr)
Value:
({ \
IC_ASSERT_CONSTANT(expr); \
expr; \
})

Require that the expression is a compile-time constant before returning it unchanged.

Raises a compile error if the expression is not constant.

Parameters
exprexpression
Returns
The same expression provided as argument.

Definition at line 31 of file assert_constant.h.

◆ IC_REQUIRE_NOT_CONSTANT

#define IC_REQUIRE_NOT_CONSTANT (   expr)
Value:
({ \
IC_ASSERT_NOT_CONSTANT(expr); \
expr; \
})

Require that the expression is not a compile-time constant before returning it unchanged.

Raises a compile error if the expression is constant.

Parameters
exprexpression
Returns
The same expression provided as argument.

Definition at line 51 of file assert_constant.h.