Validates a value as greater than or equal to a specified minimum value and less than or equal to a specified maximum value.
Files
lib_def.h
Prototype
Code Block | ||
---|---|---|
| ||
DEF_CHK_VAL(val, val_min, val_max); |
Arguments
val
Value to validate.
...
DEF_CHK_VAL()
does not validate that the maximum value (val_max
) is greater than or equal to the minimum value (val_min
).
Example Usage
Code Block | ||
---|---|---|
| ||
#define CFG_VAL -1
#if (DEF_CHK_VAL_MAX(CFG_VAL, 0u, 1000u) != DEF_OK) /* Signed CFG_VAL NOT promoted to unsigned. */
#error "CFG_VAL must be >= 0 and <= 100"
#endif |