ICU 58.2 58.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

umachine.h
Go to the documentation of this file.
1 // Copyright (C) 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: US-ASCII
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 #ifndef U_HIDE_INTERNAL_API
55 /*
56 * U_USE_CHAR16_T
57 * When defined, force use of char16_t for UChar.
58 * Note: char16_t is expected to become the default and required in the future,
59 * and this option will be removed.
60 * @internal
61 */
62 #ifdef U_USE_CHAR16_T
63 #ifdef UCHAR_TYPE
64 #undef UCHAR_TYPE
65 #endif
66 #define UCHAR_TYPE char16_t
67
68 /*
69 * In plain C, <uchar.h> is needed for the definition of char16_t
70 */
71 #ifndef __cplusplus
72 #include <uchar.h>
73 #endif
74 #endif
75 #endif /* U_HIDE_INTERNAL_API */
76
77 /*==========================================================================*/
78 /* For C wrappers, we use the symbol U_STABLE. */
79 /* This works properly if the includer is C or C++. */
80 /* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */
81 /*==========================================================================*/
82
101 #ifdef __cplusplus
102 # define U_CFUNC extern "C"
103 # define U_CDECL_BEGIN extern "C" {
104 # define U_CDECL_END }
105 #else
106 # define U_CFUNC extern
107 # define U_CDECL_BEGIN
108 # define U_CDECL_END
109 #endif
110
111 #ifndef U_ATTRIBUTE_DEPRECATED
112
117 #if U_GCC_MAJOR_MINOR >= 302
118 # define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
119
124 #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
125 # define U_ATTRIBUTE_DEPRECATED __declspec(deprecated)
126 #else
127 # define U_ATTRIBUTE_DEPRECATED
128 #endif
129 #endif
130
132 #define U_CAPI U_CFUNC U_EXPORT
133
134 #define U_STABLE U_CAPI
135
136 #define U_DRAFT U_CAPI
137
138 #define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED
139
140 #define U_OBSOLETE U_CAPI
141
142 #define U_INTERNAL U_CAPI
143
160 #if U_CPLUSPLUS_VERSION >= 11
161 /* C++11 */
162 #ifndef U_OVERRIDE
163 #define U_OVERRIDE override
164 #endif
165 #ifndef U_FINAL
166 #define U_FINAL final
167 #endif
168 #else
169 /* not C++11 - define to nothing */
170 #ifndef U_OVERRIDE
171 #define U_OVERRIDE
172 #endif
173 #ifndef U_FINAL
174 #define U_FINAL
175 #endif
176 #endif
177
178 /*==========================================================================*/
179 /* limits for int32_t etc., like in POSIX inttypes.h */
180 /*==========================================================================*/
181
182 #ifndef INT8_MIN
183
184 # define INT8_MIN ((int8_t)(-128))
185 #endif
186 #ifndef INT16_MIN
187
188 # define INT16_MIN ((int16_t)(-32767-1))
189 #endif
190 #ifndef INT32_MIN
191
192 # define INT32_MIN ((int32_t)(-2147483647-1))
193 #endif
194
195 #ifndef INT8_MAX
196
197 # define INT8_MAX ((int8_t)(127))
198 #endif
199 #ifndef INT16_MAX
200
201 # define INT16_MAX ((int16_t)(32767))
202 #endif
203 #ifndef INT32_MAX
204
205 # define INT32_MAX ((int32_t)(2147483647))
206 #endif
207
208 #ifndef UINT8_MAX
209
210 # define UINT8_MAX ((uint8_t)(255U))
211 #endif
212 #ifndef UINT16_MAX
213
214 # define UINT16_MAX ((uint16_t)(65535U))
215 #endif
216 #ifndef UINT32_MAX
217
218 # define UINT32_MAX ((uint32_t)(4294967295U))
219 #endif
220
221 #if defined(U_INT64_T_UNAVAILABLE)
222 # error int64_t is required for decimal format and rule-based number format.
223 #else
224 # ifndef INT64_C
225
230 # define INT64_C(c) c ## LL
231 # endif
232 # ifndef UINT64_C
233
238 # define UINT64_C(c) c ## ULL
239 # endif
240 # ifndef U_INT64_MIN
241
242 # define U_INT64_MIN ((int64_t)(INT64_C(-9223372036854775807)-1))
243 # endif
244 # ifndef U_INT64_MAX
245
246 # define U_INT64_MAX ((int64_t)(INT64_C(9223372036854775807)))
247 # endif
248 # ifndef U_UINT64_MAX
249
250 # define U_UINT64_MAX ((uint64_t)(UINT64_C(18446744073709551615)))
251 # endif
252 #endif
253
254 /*==========================================================================*/
255 /* Boolean data type */
256 /*==========================================================================*/
257
259 typedef int8_t UBool;
260
261 #ifndef TRUE
262
263 # define TRUE 1
264 #endif
265 #ifndef FALSE
266
267 # define FALSE 0
268 #endif
269
270
271 /*==========================================================================*/
272 /* Unicode data types */
273 /*==========================================================================*/
274
275 /* wchar_t-related definitions -------------------------------------------- */
276
277 /*
278 * \def U_WCHAR_IS_UTF16
279 * Defined if wchar_t uses UTF-16.
280 *
281 * @stable ICU 2.0
282 */
283 /*
284 * \def U_WCHAR_IS_UTF32
285 * Defined if wchar_t uses UTF-32.
286 *
287 * @stable ICU 2.0
288 */
289 #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
290 # ifdef __STDC_ISO_10646__
291 # if (U_SIZEOF_WCHAR_T==2)
292 # define U_WCHAR_IS_UTF16
293 # elif (U_SIZEOF_WCHAR_T==4)
294 # define U_WCHAR_IS_UTF32
295 # endif
296 # elif defined __UCS2__
297 # if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2)
298 # define U_WCHAR_IS_UTF16
299 # endif
300 # elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__))
301 # if (U_SIZEOF_WCHAR_T==4)
302 # define U_WCHAR_IS_UTF32
303 # endif
304 # elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED)
305 # define U_WCHAR_IS_UTF32
306 # elif U_PLATFORM_HAS_WIN32_API
307 # define U_WCHAR_IS_UTF16
308 # endif
309 #endif
310
311 /* UChar and UChar32 definitions -------------------------------------------- */
312
314 #define U_SIZEOF_UCHAR 2
315
328 #if defined(UCHAR_TYPE)
329 typedef UCHAR_TYPE UChar;
330 /* Not #elif U_HAVE_CHAR16_T -- because that is type-incompatible with pre-C++11 callers
331 typedef char16_t UChar; */
332 #elif U_SIZEOF_WCHAR_T==2
333 typedef wchar_t UChar;
334 #elif defined(__CHAR16_TYPE__)
335 typedef __CHAR16_TYPE__ UChar;
336 #else
337 typedef uint16_t UChar;
338 #endif
339
357 typedef int32_t UChar32;
358
377 #define U_SENTINEL (-1)
378
379 #include "unicode/urename.h"
380
381 #endif
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:357
uchar.h
C API: Unicode Properties.
UChar
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:337
ptypes.h
C API: Definitions of integer types of various widths.
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:259