|
ic-macros
0.1.5
|

Go to the source code of this file.
Macros | |
| #define | IC_G_CAST_NUMBER(type, min, max, expr) (type)(expr) + IC_ZERO_OR_COMPILE_ERROR((expr) >= min && (expr) <= max) |
| Compile-time constant safe cast from one number type to another. More... | |
| #define | IC_CAST_NUMBER(type, min, max, expr) |
| Safe cast from one number type to another. More... | |
| #define | IC_CAST_UNSIGNED(type, _, max, expr) |
| Safe cast from one number type to another. More... | |
| #define | IC_UINT8(expr) IC_CAST_NUMBER(uint8_t, 0, UINT8_MAX, expr) |
| Cast the expression after asserting that it is in range. More... | |
| #define | IC_UINT16(expr) IC_CAST_NUMBER(uint16_t, 0, UINT16_MAX, expr) |
| Cast the expression after asserting that it is in range. More... | |
| #define | IC_UINT32(expr) IC_CAST_NUMBER(uint32_t, 0, UINT32_MAX, expr) |
| Cast the expression after asserting that it is in range. More... | |
| #define | IC_UINT64(expr) IC_CAST_NUMBER(uint64_t, 0, UINT64_MAX, expr) |
| Cast the expression after asserting that it is in range. More... | |
| #define | IC_INT8(expr) IC_CAST_NUMBER(int8_t, INT8_MIN, INT8_MAX, expr) |
| Cast the expression after asserting that it is in range. More... | |
| #define | IC_INT16(expr) IC_CAST_NUMBER(int16_t, INT16_MIN, INT16_MAX, expr) |
| Cast the expression after asserting that it is in range. More... | |
| #define | IC_INT32(expr) IC_CAST_NUMBER(int32_t, INT32_MIN, INT32_MAX, expr) |
| Cast the expression after asserting that it is in range. More... | |
| #define | IC_INT64(expr) IC_CAST_NUMBER(int64_t, INT64_MIN, INT64_MAX, expr) |
| Cast the expression after asserting that it is in range. More... | |
| #define | IC_G_UINT8(expr) IC_G_CAST_NUMBER(uint8_t, 0, UINT8_MAX, expr) |
| Global scope only; cast the expression after asserting that it is in range. More... | |
| #define | IC_G_UINT16(expr) IC_G_CAST_NUMBER(uint16_t, 0, UINT16_MAX, expr) |
| Global scope only; cast the expression after asserting that it is in range. More... | |
| #define | IC_G_UINT32(expr) IC_G_CAST_NUMBER(uint32_t, 0, UINT32_MAX, expr) |
| Global scope only; cast the expression after asserting that it is in range. More... | |
| #define | IC_G_UINT64(expr) IC_G_CAST_NUMBER(uint64_t, 0, UINT64_MAX, expr) |
| Global scope only; cast the expression after asserting that it is in range. More... | |
| #define | IC_G_INT8(expr) IC_G_CAST_NUMBER(int8_t, INT8_MIN, INT8_MAX, expr) |
| Global scope only; cast the expression after asserting that it is in range. More... | |
| #define | IC_G_INT16(expr) IC_G_CAST_NUMBER(int16_t, INT16_MIN, INT16_MAX, expr) |
| Global scope only; cast the expression after asserting that it is in range. More... | |
| #define | IC_G_INT32(expr) IC_G_CAST_NUMBER(int32_t, INT32_MIN, INT32_MAX, expr) |
| Global scope only; cast the expression after asserting that it is in range. More... | |
| #define | IC_G_INT64(expr) IC_G_CAST_NUMBER(int64_t, INT64_MIN, INT64_MAX, expr) |
| Global scope only; cast the expression after asserting that it is in range. More... | |
| #define IC_CAST_NUMBER | ( | type, | |
| min, | |||
| max, | |||
| expr | |||
| ) |
Safe cast from one number type to another.
| type | The integer type to cast to. |
| min | The minimum value of type, e.g. 0 or INT<>_MIN. |
| max | The maximum value of type, e.g. INT<>_MAX. |
| expr | The expression to cast. |
Definition at line 34 of file integer_cast.h.
| #define IC_CAST_UNSIGNED | ( | type, | |
| _, | |||
| max, | |||
| expr | |||
| ) |
Safe cast from one number type to another.
| type | The integer type to cast to. |
| min | The minimum value of type, e.g. 0 or INT<>_MIN. |
| max | The maximum value of type, e.g. INT<>_MAX. |
| expr | The expression to cast. |
Definition at line 50 of file integer_cast.h.
| #define IC_G_CAST_NUMBER | ( | type, | |
| min, | |||
| max, | |||
| expr | |||
| ) | (type)(expr) + IC_ZERO_OR_COMPILE_ERROR((expr) >= min && (expr) <= max) |
Compile-time constant safe cast from one number type to another.
| type | The integer type to cast to. |
| min | The minimum value of type, e.g. 0 or INT<>_MIN. |
| max | The maximum value of type, e.g. INT<>_MAX. |
| expr | The expression to cast. |
Definition at line 21 of file integer_cast.h.
| #define IC_G_INT16 | ( | expr | ) | IC_G_CAST_NUMBER(int16_t, INT16_MIN, INT16_MAX, expr) |
Global scope only; cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 175 of file integer_cast.h.
| #define IC_G_INT32 | ( | expr | ) | IC_G_CAST_NUMBER(int32_t, INT32_MIN, INT32_MAX, expr) |
Global scope only; cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 182 of file integer_cast.h.
| #define IC_G_INT64 | ( | expr | ) | IC_G_CAST_NUMBER(int64_t, INT64_MIN, INT64_MAX, expr) |
Global scope only; cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 189 of file integer_cast.h.
| #define IC_G_INT8 | ( | expr | ) | IC_G_CAST_NUMBER(int8_t, INT8_MIN, INT8_MAX, expr) |
Global scope only; cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 168 of file integer_cast.h.
| #define IC_G_UINT16 | ( | expr | ) | IC_G_CAST_NUMBER(uint16_t, 0, UINT16_MAX, expr) |
Global scope only; cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 147 of file integer_cast.h.
| #define IC_G_UINT32 | ( | expr | ) | IC_G_CAST_NUMBER(uint32_t, 0, UINT32_MAX, expr) |
Global scope only; cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 154 of file integer_cast.h.
| #define IC_G_UINT64 | ( | expr | ) | IC_G_CAST_NUMBER(uint64_t, 0, UINT64_MAX, expr) |
Global scope only; cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 161 of file integer_cast.h.
| #define IC_G_UINT8 | ( | expr | ) | IC_G_CAST_NUMBER(uint8_t, 0, UINT8_MAX, expr) |
Global scope only; cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 140 of file integer_cast.h.
| #define IC_INT16 | ( | expr | ) | IC_CAST_NUMBER(int16_t, INT16_MIN, INT16_MAX, expr) |
Cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 117 of file integer_cast.h.
| #define IC_INT32 | ( | expr | ) | IC_CAST_NUMBER(int32_t, INT32_MIN, INT32_MAX, expr) |
Cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 125 of file integer_cast.h.
| #define IC_INT64 | ( | expr | ) | IC_CAST_NUMBER(int64_t, INT64_MIN, INT64_MAX, expr) |
Cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 133 of file integer_cast.h.
| #define IC_INT8 | ( | expr | ) | IC_CAST_NUMBER(int8_t, INT8_MIN, INT8_MAX, expr) |
Cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 109 of file integer_cast.h.
| #define IC_UINT16 | ( | expr | ) | IC_CAST_NUMBER(uint16_t, 0, UINT16_MAX, expr) |
Cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 85 of file integer_cast.h.
| #define IC_UINT32 | ( | expr | ) | IC_CAST_NUMBER(uint32_t, 0, UINT32_MAX, expr) |
Cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 93 of file integer_cast.h.
| #define IC_UINT64 | ( | expr | ) | IC_CAST_NUMBER(uint64_t, 0, UINT64_MAX, expr) |
Cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 101 of file integer_cast.h.
| #define IC_UINT8 | ( | expr | ) | IC_CAST_NUMBER(uint8_t, 0, UINT8_MAX, expr) |
Cast the expression after asserting that it is in range.
| expr | The expression to cast. |
Definition at line 77 of file integer_cast.h.