ICU 63.1 63.1

umachine.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ******************************************************************************
5 *
6 * Copyright (C) 1999-2015, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 ******************************************************************************
10 * file name: umachine.h
11 * encoding: UTF-8
12 * tab size: 8 (not used)
13 * indentation:4
14 *
15 * created on: 1999sep13
16 * created by: Markus W. Scherer
17 *
18 * This file defines basic types and constants for ICU to be
19 * platform-independent. umachine.h and utf.h are included into
20 * utypes.h to provide all the general definitions for ICU.
21 * All of these definitions used to be in utypes.h before
22 * the UTF-handling macros made this unmaintainable.
23 */
24
25 #ifndef __UMACHINE_H__
26 #define __UMACHINE_H__
27
28
41 /*==========================================================================*/
42 /* Include platform-dependent definitions */
43 /* which are contained in the platform-specific file platform.h */
44 /*==========================================================================*/
45
46 #include "unicode/ptypes.h" /* platform.h is included in ptypes.h */
47
48 /*
49 * ANSI C headers:
50 * stddef.h defines wchar_t
51 */
52 #include <stddef.h>
53
54 /*==========================================================================*/
55 /* For C wrappers, we use the symbol U_STABLE. */
56 /* This works properly if the includer is C or C++. */
57 /* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */
58 /*==========================================================================*/
59
78 #ifdef __cplusplus
79 # define U_CFUNC extern "C"
80 # define U_CDECL_BEGIN extern "C" {
81 # define U_CDECL_END }
82 #else
83 # define U_CFUNC extern
84 # define U_CDECL_BEGIN
85 # define U_CDECL_END
86 #endif
87
88 #ifndef U_ATTRIBUTE_DEPRECATED
89
94 #if U_GCC_MAJOR_MINOR >= 302
95 # define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
96
101 #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
102 # define U_ATTRIBUTE_DEPRECATED __declspec(deprecated)
103 #else
104 # define U_ATTRIBUTE_DEPRECATED
105 #endif
106 #endif
107
109 #define U_CAPI U_CFUNC U_EXPORT
110
111 #define U_STABLE U_CAPI
112
113 #define U_DRAFT U_CAPI
114
115 #define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED
116
117 #define U_OBSOLETE U_CAPI
118
119 #define U_INTERNAL U_CAPI
120
128 #ifndef U_OVERRIDE
129 #define U_OVERRIDE override
130 #endif
131
139 #if !defined(U_FINAL) || defined(U_IN_DOXYGEN)
140 #define U_FINAL final
141 #endif
142
143
144 /*==========================================================================*/
145 /* limits for int32_t etc., like in POSIX inttypes.h */
146 /*==========================================================================*/
147
148 #ifndef INT8_MIN
149
150 # define INT8_MIN ((int8_t)(-128))
151 #endif
152 #ifndef INT16_MIN
153
154 # define INT16_MIN ((int16_t)(-32767-1))
155 #endif
156 #ifndef INT32_MIN
157
158 # define INT32_MIN ((int32_t)(-2147483647-1))
159 #endif
160
161 #ifndef INT8_MAX
162
163 # define INT8_MAX ((int8_t)(127))
164 #endif
165 #ifndef INT16_MAX
166
167 # define INT16_MAX ((int16_t)(32767))
168 #endif
169 #ifndef INT32_MAX
170
171 # define INT32_MAX ((int32_t)(2147483647))
172 #endif
173
174 #ifndef UINT8_MAX
175
176 # define UINT8_MAX ((uint8_t)(255U))
177 #endif
178 #ifndef UINT16_MAX
179
180 # define UINT16_MAX ((uint16_t)(65535U))
181 #endif
182 #ifndef UINT32_MAX
183
184 # define UINT32_MAX ((uint32_t)(4294967295U))
185 #endif
186
187 #if defined(U_INT64_T_UNAVAILABLE)
188 # error int64_t is required for decimal format and rule-based number format.
189 #else
190 # ifndef INT64_C
191
196 # define INT64_C(c) c ## LL
197 # endif
198 # ifndef UINT64_C
199
204 # define UINT64_C(c) c ## ULL
205 # endif
206 # ifndef U_INT64_MIN
207
208 # define U_INT64_MIN ((int64_t)(INT64_C(-9223372036854775807)-1))
209 # endif
210 # ifndef U_INT64_MAX
211
212 # define U_INT64_MAX ((int64_t)(INT64_C(9223372036854775807)))
213 # endif
214 # ifndef U_UINT64_MAX
215
216 # define U_UINT64_MAX ((uint64_t)(UINT64_C(18446744073709551615)))
217 # endif
218 #endif
219
220 /*==========================================================================*/
221 /* Boolean data type */
222 /*==========================================================================*/
223
225 typedef int8_t UBool;
226
227 #ifndef TRUE
228
229 # define TRUE 1
230 #endif
231 #ifndef FALSE
232
233 # define FALSE 0
234 #endif
235
236
237 /*==========================================================================*/
238 /* Unicode data types */
239 /*==========================================================================*/
240
241 /* wchar_t-related definitions -------------------------------------------- */
242
243 /*
244 * \def U_WCHAR_IS_UTF16
245 * Defined if wchar_t uses UTF-16.
246 *
247 * @stable ICU 2.0
248 */
249 /*
250 * \def U_WCHAR_IS_UTF32
251 * Defined if wchar_t uses UTF-32.
252 *
253 * @stable ICU 2.0
254 */
255 #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
256 # ifdef __STDC_ISO_10646__
257 # if (U_SIZEOF_WCHAR_T==2)
258 # define U_WCHAR_IS_UTF16
259 # elif (U_SIZEOF_WCHAR_T==4)
260 # define U_WCHAR_IS_UTF32
261 # endif
262 # elif defined __UCS2__
263 # if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2)
264 # define U_WCHAR_IS_UTF16
265 # endif
266 # elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__))
267 # if (U_SIZEOF_WCHAR_T==4)
268 # define U_WCHAR_IS_UTF32
269 # endif
270 # elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED)
271 # define U_WCHAR_IS_UTF32
272 # elif U_PLATFORM_HAS_WIN32_API
273 # define U_WCHAR_IS_UTF16
274 # endif
275 #endif
276
277 /* UChar and UChar32 definitions -------------------------------------------- */
278
280 #define U_SIZEOF_UCHAR 2
281
287 #if (U_PLATFORM == U_PF_AIX) && defined(__cplusplus) &&(U_CPLUSPLUS_VERSION < 11)
288 // for AIX, uchar.h needs to be included
289 # include <uchar.h>
290 # define U_CHAR16_IS_TYPEDEF 1
291 #elif defined(_MSC_VER) && (_MSC_VER < 1900)
292 // Versions of Visual Studio/MSVC below 2015 do not support char16_t as a real type,
293 // and instead use a typedef. https://msdn.microsoft.com/library/bb531344.aspx
294 # define U_CHAR16_IS_TYPEDEF 1
295 #else
296 # define U_CHAR16_IS_TYPEDEF 0
297 #endif
298
299
324 #if 1
325 // #if 1 is normal. UChar defaults to char16_t in C++.
326 // For configuration testing of UChar=uint16_t temporarily change this to #if 0.
327 // The intltest Makefile #defines UCHAR_TYPE=char16_t,
328 // so we only #define it to uint16_t if it is undefined so far.
329 #elif !defined(UCHAR_TYPE)
330 # define UCHAR_TYPE uint16_t
331 #endif
332
333 #if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || \
334 defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
335 // Inside the ICU library code, never configurable.
336 typedef char16_t UChar;
337 #elif defined(UCHAR_TYPE)
338 typedef UCHAR_TYPE UChar;
339 #elif defined(__cplusplus)
340 typedef char16_t UChar;
341 #else
342 typedef uint16_t UChar;
343 #endif
344
364 #if U_SIZEOF_WCHAR_T==2
365 typedef wchar_t OldUChar;
366 #elif defined(__CHAR16_TYPE__)
367 typedef __CHAR16_TYPE__ OldUChar;
368 #else
369 typedef uint16_t OldUChar;
370 #endif
371
389 typedef int32_t UChar32;
390
409 #define U_SENTINEL (-1)
410
411 #include "unicode/urename.h"
412
413 #endif
OldUChar
uint16_t OldUChar
Default ICU 58 definition of UChar.
Definition: umachine.h:369
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:389
uchar.h
C API: Unicode Properties.
UChar
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:342
ptypes.h
C API: Definitions of integer types of various widths.
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225