boundscheck.h
Go to the documentation of this file.
1 #pragma once
2 #ifndef _BOUNDSCHECK_H
3 #define _BOUNDSCHECK_H
4 
5 /******************************************************
6  * BOUNDS CHECKING MACROS *
7  * *
8  * Checks value to be between min and max *
9  * return is value if check is successful, and err *
10  * if check fails *
11  * *
12  * The checks are only made if the symbol: *
13  * BOUNDS_CHECK_ALL *
14  * has been defined, else the macro evaluates to *
15  * value without any additional overhead *
16  ******************************************************/
17 
18 
19 #ifdef BOUNDS_CHECK_ALL
20 #define BOUNDSCHECK(value,min,max,err) ( (value >= min) && (value <= max)) ? value : err
21 #else
22 #define BOUNDSCHECK(value,min,max,err) value
23 #endif
24 
25 #endif /* _BOUNDSCHECK_H */