|
| 1 | +#pragma once |
| 2 | + |
| 3 | +/** @file |
| 4 | + * This file contains various shared utility macros that make writing function |
| 5 | + * style macros easier. |
| 6 | +*/ |
| 7 | + |
| 8 | +#if !defined(UNUSED) |
| 9 | +/** @brief Used to suppress unused parameter compiler warnings */ |
| 10 | +#define UNUSED(x) \ |
| 11 | + (void)(x) |
| 12 | +#endif |
| 13 | + |
| 14 | +/** @brief Compile time calculation of an array size */ |
| 15 | +#if !defined(_countof) |
| 16 | +#define _countof(x) \ |
| 17 | + (sizeof((x)) / sizeof ((x)[0])) |
| 18 | +#endif |
| 19 | + |
| 20 | +/** @brief Obtain a pointer to 1 *element* past the end of an array */ |
| 21 | +#if !defined(_end_range_address) |
| 22 | +#define _end_range_address(array) \ |
| 23 | + ((array) + _countof((array))) |
| 24 | +#endif |
| 25 | + |
| 26 | +/** @brief Obtain a pointer to 1 *byte* past the end of an array */ |
| 27 | +#if !defined(_end_range_byte_address) |
| 28 | +#define _end_range_byte_address(array) \ |
| 29 | + (((byte*)(array)) + sizeof((array))) |
| 30 | +#endif |
| 31 | + |
| 32 | +/** @brief Pre-processor arithmetic increment (pulled from Boost.Preprocessor) */ |
| 33 | +#if !defined(PP_INC) |
| 34 | +#define PP_INC(x) \ |
| 35 | + PP_INC_I(x) |
| 36 | +#endif |
| 37 | + |
| 38 | +/// @cond |
| 39 | +// PP_INC() support macros |
| 40 | +#define PP_INC_I(x) PP_INC_ ## x |
| 41 | +#define PP_INC_0 1 // NOSONAR |
| 42 | +#define PP_INC_1 2 // NOSONAR |
| 43 | +#define PP_INC_2 3 // NOSONAR |
| 44 | +#define PP_INC_3 4 // NOSONAR |
| 45 | +#define PP_INC_4 5 // NOSONAR |
| 46 | +#define PP_INC_5 6 // NOSONAR |
| 47 | +#define PP_INC_6 7 // NOSONAR |
| 48 | +#define PP_INC_7 8 // NOSONAR |
| 49 | +#define PP_INC_8 9 // NOSONAR |
| 50 | +#define PP_INC_9 10 // NOSONAR |
| 51 | +#define PP_INC_10 11 // NOSONAR |
| 52 | +#define PP_INC_11 12 // NOSONAR |
| 53 | +#define PP_INC_12 13 // NOSONAR |
| 54 | +/// @endcond |
| 55 | + |
| 56 | +/// @cond |
| 57 | +// CONCAT() support macros |
| 58 | +#define CAT_HELPER(a, b) a ## b |
| 59 | +/// @endcond |
| 60 | + |
| 61 | +/** @brief Concatenate A & B *after* macro expansion */ |
| 62 | +#if !defined(CONCAT) |
| 63 | +#define CONCAT(A, B) \ |
| 64 | + CAT_HELPER(A, B) |
| 65 | +#endif |
0 commit comments