csnip  0.1
Macros
Numeric limits

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...
 

Detailed Description

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.

Macro Definition Documentation

◆ csnip_limit_Int

#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}

◆ csnip_limit_Maxi

#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().

◆ 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.