|
14 | 14 |
|
15 | 15 | #define __STDC_LIMIT_MACROS ///< for fixed-width integer limits |
16 | 16 |
|
17 | | -#include <limits.h> |
18 | 17 | #include <stdint.h> |
| 18 | +#include <limits.h> |
19 | 19 |
|
20 | 20 | /// API major version |
21 | 21 | #define XCHANGE_MAJOR_VERSION 1 |
@@ -98,33 +98,51 @@ typedef int XType; ///< SMA-X data type. |
98 | 98 | #define X_STRUCT 'X' ///< \hideinitializer XType for an XStructure or array thereof |
99 | 99 | #define X_FIELD '-' ///< \hideinitializer XType for an XField or array thereof |
100 | 100 |
|
| 101 | +#ifndef INT16_MAX |
| 102 | +# define INT16_MAX 32767 ///< Largest 16-bit integer value |
| 103 | +#endif |
| 104 | + |
| 105 | +#ifndef INT32_MAX |
| 106 | +# define INT32_MAX 2147483647 ///< Largest 32-bit integer value |
| 107 | +#endif |
| 108 | + |
| 109 | +#ifndef INT64_MAX |
| 110 | +# define INT64_MAX 9223372036854775807LL ///< Largest 64-bit integer value |
| 111 | +#endif |
| 112 | + |
101 | 113 | // Platform-specific width integer types |
102 | 114 | #if SHRT_MAX == INT16_MAX |
103 | 115 | # define X_SHORT X_INT16 ///< \hideinitializer native `short` XType |
104 | 116 | #elif SHRT_MAX == INT32_MAX |
105 | 117 | # define X_SHORT X_INT32 ///< \hideinitializer native `short` XType |
106 | | -#else |
| 118 | +#elif SHRT_MAX == INT64_MAX |
107 | 119 | # define X_SHORT X_INT64 ///< \hideinitializer native `short` XType |
| 120 | +#else |
| 121 | +# error "xchange.h: Unmatched SHRT_MAX" |
108 | 122 | #endif |
109 | 123 |
|
110 | 124 | #if INT_MAX == INT16_MAX |
111 | 125 | # define X_INT X_INT16 ///< \hideinitializer native `int` XType |
112 | 126 | #elif INT_MAX == INT32_MAX |
113 | 127 | # define X_INT X_INT32 ///< \hideinitializer native `int` XType |
114 | | -#else |
| 128 | +#elif INT_MAX == INT64_MAX |
115 | 129 | # define X_INT X_INT64 ///< \hideinitializer native `int` XType |
| 130 | +#else |
| 131 | +# error "xchange.h: Unmatched INT_MAX" |
116 | 132 | #endif |
117 | 133 |
|
118 | 134 | #if LONG_MAX == INT32_MAX |
119 | 135 | # define X_LONG X_INT32 ///< \hideinitializer native `long` XType |
120 | | -#else |
| 136 | +#elif LONG_MAX == INT64_MAX |
121 | 137 | # define X_LONG X_INT64 ///< \hideinitializer native `long` XType |
| 138 | +#else |
| 139 | +# error "xchange.h: Unmatched LONG_MAX" |
122 | 140 | #endif |
123 | 141 |
|
124 | 142 | #if !defined(LLONG_MAX) || LLONG_MAX == INT64_MAX |
125 | 143 | # define X_LLONG X_INT64 ///< \hideinitializer native `long long` XType |
126 | 144 | #else |
127 | | -# define X_LLONG X_UNDEFINED ///< \hideinitializer no native `long long` XType |
| 145 | +# define X_LLONG X_UNDEFINED ///< \hideinitializer no native `long long` XType |
128 | 146 | #endif |
129 | 147 |
|
130 | 148 | #define X_SEP ":" ///< sepatator for patterning of notification channels, e.g. "changed:<table>:<key>" |
|
0 commit comments