101
101
/* We are mixing C and C++, so we wan the C limit macros in the C++ too */
102
102
/* Enable some extra C99 extensions */
104
#define __STDC_LIMIT_MACROS
105
104
#define __STDC_FORMAT_MACROS
107
105
#include <inttypes.h>
109
#error "You must have stdint!"
107
We include the following because currently Google #$@#$ Protocol Buffers possibly break stdint defines.
108
Or I am wrong, very possible, and hope someone finds the solution.
110
Taken from /usr/include/stdint.h
113
/* 7.18.2 Limits of specified-width integer types:
114
* These #defines specify the minimum and maximum limits
115
* of each of the types declared above.
119
/* 7.18.2.1 Limits of exact-width integer types */
121
#define INT16_MAX 32767
122
#define INT32_MAX 2147483647
123
#define INT64_MAX 9223372036854775807LL
125
#define INT8_MIN -128
126
#define INT16_MIN -32768
128
Note: the literal "most negative int" cannot be written in C --
129
the rules in the standard (section 6.4.4.1 in C99) will give it
130
an unsigned type, so INT32_MIN (and the most negative member of
131
any larger signed type) must be written via a constant expression.
133
#define INT32_MIN (-INT32_MAX-1)
134
#define INT64_MIN (-INT64_MAX-1)
136
#define UINT8_MAX 255
137
#define UINT16_MAX 65535
138
#define UINT32_MAX 4294967295U
139
#define UINT64_MAX 18446744073709551615ULL
141
/* 7.18.2.2 Limits of minimum-width integer types */
142
#define INT_LEAST8_MIN INT8_MIN
143
#define INT_LEAST16_MIN INT16_MIN
144
#define INT_LEAST32_MIN INT32_MIN
145
#define INT_LEAST64_MIN INT64_MIN
147
#define INT_LEAST8_MAX INT8_MAX
148
#define INT_LEAST16_MAX INT16_MAX
149
#define INT_LEAST32_MAX INT32_MAX
150
#define INT_LEAST64_MAX INT64_MAX
152
#define UINT_LEAST8_MAX UINT8_MAX
153
#define UINT_LEAST16_MAX UINT16_MAX
154
#define UINT_LEAST32_MAX UINT32_MAX
155
#define UINT_LEAST64_MAX UINT64_MAX
157
/* 7.18.2.3 Limits of fastest minimum-width integer types */
158
#define INT_FAST8_MIN INT8_MIN
159
#define INT_FAST16_MIN INT16_MIN
160
#define INT_FAST32_MIN INT32_MIN
161
#define INT_FAST64_MIN INT64_MIN
163
#define INT_FAST8_MAX INT8_MAX
164
#define INT_FAST16_MAX INT16_MAX
165
#define INT_FAST32_MAX INT32_MAX
166
#define INT_FAST64_MAX INT64_MAX
168
#define UINT_FAST8_MAX UINT8_MAX
169
#define UINT_FAST16_MAX UINT16_MAX
170
#define UINT_FAST32_MAX UINT32_MAX
171
#define UINT_FAST64_MAX UINT64_MAX
173
/* 7.18.2.4 Limits of integer types capable of holding object pointers */
176
#define INTPTR_MIN INT64_MIN
177
#define INTPTR_MAX INT64_MAX
179
#define INTPTR_MIN INT32_MIN
180
#define INTPTR_MAX INT32_MAX
184
#define UINTPTR_MAX UINT64_MAX
186
#define UINTPTR_MAX UINT32_MAX
189
/* 7.18.2.5 Limits of greatest-width integer types */
190
#define INTMAX_MIN INT64_MIN
191
#define INTMAX_MAX INT64_MAX
193
#define UINTMAX_MAX UINT64_MAX
197
#define PTRDIFF_MIN INT64_MIN
198
#define PTRDIFF_MAX INT64_MAX
200
#define PTRDIFF_MIN INT32_MIN
201
#define PTRDIFF_MAX INT32_MAX
204
/* We have no sig_atomic_t yet, so no SIG_ATOMIC_{MIN,MAX}.
205
Should end up being {-127,127} or {0,255} ... or bigger.
206
My bet would be on one of {U}INT32_{MIN,MAX}. */
209
#define SIZE_MAX UINT64_MAX
211
#define SIZE_MAX UINT32_MAX
215
# ifdef __WCHAR_MAX__
216
# define WCHAR_MAX __WCHAR_MAX__
218
# define WCHAR_MAX 0x7fffffff
222
/* WCHAR_MIN should be 0 if wchar_t is an unsigned type and
223
(-WCHAR_MAX-1) if wchar_t is a signed type. Unfortunately,
224
it turns out that -fshort-wchar changes the signedness of
227
# if WCHAR_MAX == 0xffff
230
# define WCHAR_MIN (-WCHAR_MAX-1)
234
#define WINT_MIN INT32_MIN
235
#define WINT_MAX INT32_MAX
237
#define SIG_ATOMIC_MIN INT32_MIN
238
#define SIG_ATOMIC_MAX INT32_MAX
241
#error "You must have inttypes!"