csnip
0.1
|
Type generic numeric limit macros. More...
Macros | |
#define | csnip_limit_Int(x) |
Compute the limits of a given integer type. More... | |
#define | csnip_limit_Mini(x) (csnip_limit_Int(x)[0]) |
Type generic minimum value function. More... | |
#define | csnip_limit_Maxi(x) (csnip_limit_Int(x)[1]) |
Type generic maximum value function. More... | |
Macros to find the minimum and maximum range of supported integer types. They can be useful, for example, to implement type-generic macros.
Requirements: C11, in particular support for _Generic
.
#define csnip_limit_Int | ( | x | ) |
Expression macro. For an integer expression, return the limits of that type as an array of 2, containing in the first element the minimum and the second element the maximum. For example,
csnip_limit_Int(42)
evaluates to the array
(const int[]){INT_MIN, INT_MAX}
#define csnip_limit_Maxi | ( | x | ) | (csnip_limit_Int(x)[1]) |
Given an expression x of integer type, return the maximum value of that integer type. See also csnip_limit_Mini().
#define csnip_limit_Mini | ( | x | ) | (csnip_limit_Int(x)[0]) |
Given an expression x of integer type, return the minimum value of that integer type. For example,
csnip_limit_Mini(35)
evaluates to INT_MIN
, whereas
csnip_limit_Mini(35l)
evaluates to LONG_MIN
.