jpayne@69: # endif
jpayne@69: #elif defined(_AIX) || defined(__TOS_AIX__)
jpayne@69: # define U_PLATFORM U_PF_AIX
jpayne@69: #elif defined(_hpux) || defined(hpux) || defined(__hpux)
jpayne@69: # define U_PLATFORM U_PF_HPUX
jpayne@69: #elif defined(sgi) || defined(__sgi)
jpayne@69: # define U_PLATFORM U_PF_IRIX
jpayne@69: #elif defined(__QNX__) || defined(__QNXNTO__)
jpayne@69: # define U_PLATFORM U_PF_QNX
jpayne@69: #elif defined(__TOS_MVS__)
jpayne@69: # define U_PLATFORM U_PF_OS390
jpayne@69: #elif defined(__OS400__) || defined(__TOS_OS400__)
jpayne@69: # define U_PLATFORM U_PF_OS400
jpayne@69: #elif defined(__EMSCRIPTEN__)
jpayne@69: # define U_PLATFORM U_PF_EMSCRIPTEN
jpayne@69: #else
jpayne@69: # define U_PLATFORM U_PF_UNKNOWN
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def CYGWINMSVC
jpayne@69: * Defined if this is Windows with Cygwin, but using MSVC rather than gcc.
jpayne@69: * Otherwise undefined.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: /* Commented out because this is already set in mh-cygwin-msvc
jpayne@69: #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER)
jpayne@69: # define CYGWINMSVC
jpayne@69: #endif
jpayne@69: */
jpayne@69: #ifdef U_IN_DOXYGEN
jpayne@69: # define CYGWINMSVC
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_PLATFORM_USES_ONLY_WIN32_API
jpayne@69: * Defines whether the platform uses only the Win32 API.
jpayne@69: * Set to 1 for Windows/MSVC and MinGW but not Cygwin.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_PLATFORM_USES_ONLY_WIN32_API
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC)
jpayne@69: # define U_PLATFORM_USES_ONLY_WIN32_API 1
jpayne@69: #else
jpayne@69: /* Cygwin implements POSIX. */
jpayne@69: # define U_PLATFORM_USES_ONLY_WIN32_API 0
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_PLATFORM_HAS_WIN32_API
jpayne@69: * Defines whether the Win32 API is available on the platform.
jpayne@69: * Set to 1 for Windows/MSVC, MinGW and Cygwin.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_PLATFORM_HAS_WIN32_API
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
jpayne@69: # define U_PLATFORM_HAS_WIN32_API 1
jpayne@69: #else
jpayne@69: # define U_PLATFORM_HAS_WIN32_API 0
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_PLATFORM_HAS_WINUWP_API
jpayne@69: * Defines whether target is intended for Universal Windows Platform API
jpayne@69: * Set to 1 for Windows10 Release Solution Configuration
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_PLATFORM_HAS_WINUWP_API
jpayne@69: /* Use the predefined value. */
jpayne@69: #else
jpayne@69: # define U_PLATFORM_HAS_WINUWP_API 0
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_PLATFORM_IMPLEMENTS_POSIX
jpayne@69: * Defines whether the platform implements (most of) the POSIX API.
jpayne@69: * Set to 1 for Cygwin and most other platforms.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_PLATFORM_IMPLEMENTS_POSIX
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif U_PLATFORM_USES_ONLY_WIN32_API
jpayne@69: # define U_PLATFORM_IMPLEMENTS_POSIX 0
jpayne@69: #else
jpayne@69: # define U_PLATFORM_IMPLEMENTS_POSIX 1
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_PLATFORM_IS_LINUX_BASED
jpayne@69: * Defines whether the platform is Linux or one of its derivatives.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_PLATFORM_IS_LINUX_BASED
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= 4499
jpayne@69: # define U_PLATFORM_IS_LINUX_BASED 1
jpayne@69: #else
jpayne@69: # define U_PLATFORM_IS_LINUX_BASED 0
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_PLATFORM_IS_DARWIN_BASED
jpayne@69: * Defines whether the platform is Darwin or one of its derivatives.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_PLATFORM_IS_DARWIN_BASED
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE
jpayne@69: # define U_PLATFORM_IS_DARWIN_BASED 1
jpayne@69: #else
jpayne@69: # define U_PLATFORM_IS_DARWIN_BASED 0
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_HAVE_STDINT_H
jpayne@69: * Defines whether stdint.h is available. It is a C99 standard header.
jpayne@69: * We used to include inttypes.h which includes stdint.h but we usually do not need
jpayne@69: * the additional definitions from inttypes.h.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_HAVE_STDINT_H
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif U_PLATFORM_USES_ONLY_WIN32_API
jpayne@69: # if defined(__BORLANDC__) || U_PLATFORM == U_PF_MINGW || (defined(_MSC_VER) && _MSC_VER>=1600)
jpayne@69: /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */
jpayne@69: # define U_HAVE_STDINT_H 1
jpayne@69: # else
jpayne@69: # define U_HAVE_STDINT_H 0
jpayne@69: # endif
jpayne@69: #elif U_PLATFORM == U_PF_SOLARIS
jpayne@69: /* Solaris has inttypes.h but not stdint.h. */
jpayne@69: # define U_HAVE_STDINT_H 0
jpayne@69: #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
jpayne@69: /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
jpayne@69: # define U_HAVE_STDINT_H 0
jpayne@69: #else
jpayne@69: # define U_HAVE_STDINT_H 1
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_HAVE_INTTYPES_H
jpayne@69: * Defines whether inttypes.h is available. It is a C99 standard header.
jpayne@69: * We include inttypes.h where it is available but stdint.h is not.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_HAVE_INTTYPES_H
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif U_PLATFORM == U_PF_SOLARIS
jpayne@69: /* Solaris has inttypes.h but not stdint.h. */
jpayne@69: # define U_HAVE_INTTYPES_H 1
jpayne@69: #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
jpayne@69: /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
jpayne@69: # define U_HAVE_INTTYPES_H 1
jpayne@69: #else
jpayne@69: /* Most platforms have both inttypes.h and stdint.h, or neither. */
jpayne@69: # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H
jpayne@69: #endif
jpayne@69:
jpayne@69: /*===========================================================================*/
jpayne@69: /** @{ Compiler and environment features */
jpayne@69: /*===========================================================================*/
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_GCC_MAJOR_MINOR
jpayne@69: * Indicates whether the compiler is gcc (test for != 0),
jpayne@69: * and if so, contains its major (times 100) and minor version numbers.
jpayne@69: * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0.
jpayne@69: *
jpayne@69: * For example, for testing for whether we have gcc, and whether it's 4.6 or higher,
jpayne@69: * use "#if U_GCC_MAJOR_MINOR >= 406".
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef __GNUC__
jpayne@69: # define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__)
jpayne@69: #else
jpayne@69: # define U_GCC_MAJOR_MINOR 0
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_IS_BIG_ENDIAN
jpayne@69: * Determines the endianness of the platform.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_IS_BIG_ENDIAN
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)
jpayne@69: # define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
jpayne@69: #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
jpayne@69: /* gcc */
jpayne@69: # define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
jpayne@69: #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
jpayne@69: # define U_IS_BIG_ENDIAN 1
jpayne@69: #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
jpayne@69: # define U_IS_BIG_ENDIAN 0
jpayne@69: #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__)
jpayne@69: /* These platforms do not appear to predefine any endianness macros. */
jpayne@69: # define U_IS_BIG_ENDIAN 1
jpayne@69: #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0)
jpayne@69: /* HPPA do not appear to predefine any endianness macros. */
jpayne@69: # define U_IS_BIG_ENDIAN 1
jpayne@69: #elif defined(sparc) || defined(__sparc) || defined(__sparc__)
jpayne@69: /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */
jpayne@69: # define U_IS_BIG_ENDIAN 1
jpayne@69: #else
jpayne@69: # define U_IS_BIG_ENDIAN 0
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_HAVE_PLACEMENT_NEW
jpayne@69: * Determines whether to override placement new and delete for STL.
jpayne@69: * @stable ICU 2.6
jpayne@69: */
jpayne@69: #ifdef U_HAVE_PLACEMENT_NEW
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif defined(__BORLANDC__)
jpayne@69: # define U_HAVE_PLACEMENT_NEW 0
jpayne@69: #else
jpayne@69: # define U_HAVE_PLACEMENT_NEW 1
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_HAVE_DEBUG_LOCATION_NEW
jpayne@69: * Define this to define the MFC debug version of the operator new.
jpayne@69: *
jpayne@69: * @stable ICU 3.4
jpayne@69: */
jpayne@69: #ifdef U_HAVE_DEBUG_LOCATION_NEW
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif defined(_MSC_VER)
jpayne@69: # define U_HAVE_DEBUG_LOCATION_NEW 1
jpayne@69: #else
jpayne@69: # define U_HAVE_DEBUG_LOCATION_NEW 0
jpayne@69: #endif
jpayne@69:
jpayne@69: /* Compatibility with compilers other than clang: http://clang.llvm.org/docs/LanguageExtensions.html */
jpayne@69: #ifdef __has_attribute
jpayne@69: # define UPRV_HAS_ATTRIBUTE(x) __has_attribute(x)
jpayne@69: #else
jpayne@69: # define UPRV_HAS_ATTRIBUTE(x) 0
jpayne@69: #endif
jpayne@69: #ifdef __has_cpp_attribute
jpayne@69: # define UPRV_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
jpayne@69: #else
jpayne@69: # define UPRV_HAS_CPP_ATTRIBUTE(x) 0
jpayne@69: #endif
jpayne@69: #ifdef __has_declspec_attribute
jpayne@69: # define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x)
jpayne@69: #else
jpayne@69: # define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) 0
jpayne@69: #endif
jpayne@69: #ifdef __has_builtin
jpayne@69: # define UPRV_HAS_BUILTIN(x) __has_builtin(x)
jpayne@69: #else
jpayne@69: # define UPRV_HAS_BUILTIN(x) 0
jpayne@69: #endif
jpayne@69: #ifdef __has_feature
jpayne@69: # define UPRV_HAS_FEATURE(x) __has_feature(x)
jpayne@69: #else
jpayne@69: # define UPRV_HAS_FEATURE(x) 0
jpayne@69: #endif
jpayne@69: #ifdef __has_extension
jpayne@69: # define UPRV_HAS_EXTENSION(x) __has_extension(x)
jpayne@69: #else
jpayne@69: # define UPRV_HAS_EXTENSION(x) 0
jpayne@69: #endif
jpayne@69: #ifdef __has_warning
jpayne@69: # define UPRV_HAS_WARNING(x) __has_warning(x)
jpayne@69: #else
jpayne@69: # define UPRV_HAS_WARNING(x) 0
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_MALLOC_ATTR
jpayne@69: * Attribute to mark functions as malloc-like
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #if defined(__GNUC__) && __GNUC__>=3
jpayne@69: # define U_MALLOC_ATTR __attribute__ ((__malloc__))
jpayne@69: #else
jpayne@69: # define U_MALLOC_ATTR
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_ALLOC_SIZE_ATTR
jpayne@69: * Attribute to specify the size of the allocated buffer for malloc-like functions
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #if (defined(__GNUC__) && \
jpayne@69: (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \
jpayne@69: UPRV_HAS_ATTRIBUTE(alloc_size)
jpayne@69: # define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X)))
jpayne@69: # define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y)))
jpayne@69: #else
jpayne@69: # define U_ALLOC_SIZE_ATTR(X)
jpayne@69: # define U_ALLOC_SIZE_ATTR2(X,Y)
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_CPLUSPLUS_VERSION
jpayne@69: * 0 if no C++; 1, 11, 14, ... if C++.
jpayne@69: * Support for specific features cannot always be determined by the C++ version alone.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_CPLUSPLUS_VERSION
jpayne@69: # if U_CPLUSPLUS_VERSION != 0 && !defined(__cplusplus)
jpayne@69: # undef U_CPLUSPLUS_VERSION
jpayne@69: # define U_CPLUSPLUS_VERSION 0
jpayne@69: # endif
jpayne@69: /* Otherwise use the predefined value. */
jpayne@69: #elif !defined(__cplusplus)
jpayne@69: # define U_CPLUSPLUS_VERSION 0
jpayne@69: #elif __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
jpayne@69: # define U_CPLUSPLUS_VERSION 14
jpayne@69: #elif __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
jpayne@69: # define U_CPLUSPLUS_VERSION 11
jpayne@69: #else
jpayne@69: // C++98 or C++03
jpayne@69: # define U_CPLUSPLUS_VERSION 1
jpayne@69: #endif
jpayne@69:
jpayne@69: #if (U_PLATFORM == U_PF_AIX || U_PLATFORM == U_PF_OS390) && defined(__cplusplus) &&(U_CPLUSPLUS_VERSION < 11)
jpayne@69: // add in std::nullptr_t
jpayne@69: namespace std {
jpayne@69: typedef decltype(nullptr) nullptr_t;
jpayne@69: };
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_NOEXCEPT
jpayne@69: * "noexcept" if supported, otherwise empty.
jpayne@69: * Some code, especially STL containers, uses move semantics of objects only
jpayne@69: * if the move constructor and the move operator are declared as not throwing exceptions.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_NOEXCEPT
jpayne@69: /* Use the predefined value. */
jpayne@69: #else
jpayne@69: # define U_NOEXCEPT noexcept
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_FALLTHROUGH
jpayne@69: * Annotate intentional fall-through between switch labels.
jpayne@69: * http://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifndef __cplusplus
jpayne@69: // Not for C.
jpayne@69: #elif defined(U_FALLTHROUGH)
jpayne@69: // Use the predefined value.
jpayne@69: #elif defined(__clang__)
jpayne@69: // Test for compiler vs. feature separately.
jpayne@69: // Other compilers might choke on the feature test.
jpayne@69: # if UPRV_HAS_CPP_ATTRIBUTE(clang::fallthrough) || \
jpayne@69: (UPRV_HAS_FEATURE(cxx_attributes) && \
jpayne@69: UPRV_HAS_WARNING("-Wimplicit-fallthrough"))
jpayne@69: # define U_FALLTHROUGH [[clang::fallthrough]]
jpayne@69: # endif
jpayne@69: #elif defined(__GNUC__) && (__GNUC__ >= 7)
jpayne@69: # define U_FALLTHROUGH __attribute__((fallthrough))
jpayne@69: #endif
jpayne@69:
jpayne@69: #ifndef U_FALLTHROUGH
jpayne@69: # define U_FALLTHROUGH
jpayne@69: #endif
jpayne@69:
jpayne@69: /** @} */
jpayne@69:
jpayne@69: /*===========================================================================*/
jpayne@69: /** @{ Character data types */
jpayne@69: /*===========================================================================*/
jpayne@69:
jpayne@69: /**
jpayne@69: * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: #define U_ASCII_FAMILY 0
jpayne@69:
jpayne@69: /**
jpayne@69: * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform.
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: #define U_EBCDIC_FAMILY 1
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_CHARSET_FAMILY
jpayne@69: *
jpayne@69: * These definitions allow to specify the encoding of text
jpayne@69: * in the char data type as defined by the platform and the compiler.
jpayne@69: * It is enough to determine the code point values of "invariant characters",
jpayne@69: * which are the ones shared by all encodings that are in use
jpayne@69: * on a given platform.
jpayne@69: *
jpayne@69: * Those "invariant characters" should be all the uppercase and lowercase
jpayne@69: * latin letters, the digits, the space, and "basic punctuation".
jpayne@69: * Also, '\\n', '\\r', '\\t' should be available.
jpayne@69: *
jpayne@69: * The list of "invariant characters" is:
jpayne@69: * \code
jpayne@69: * A-Z a-z 0-9 SPACE " % & ' ( ) * + , - . / : ; < = > ? _
jpayne@69: * \endcode
jpayne@69: *
jpayne@69: * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)
jpayne@69: *
jpayne@69: * This matches the IBM Syntactic Character Set (CS 640).
jpayne@69: *
jpayne@69: * In other words, all the graphic characters in 7-bit ASCII should
jpayne@69: * be safely accessible except the following:
jpayne@69: *
jpayne@69: * \code
jpayne@69: * '\'
jpayne@69: * '['
jpayne@69: * ']'
jpayne@69: * '{'
jpayne@69: * '}'
jpayne@69: * '^'
jpayne@69: * '~'
jpayne@69: * '!'
jpayne@69: * '#'
jpayne@69: * '|'
jpayne@69: * '$'
jpayne@69: * '@'
jpayne@69: * '`'
jpayne@69: * \endcode
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: #ifdef U_CHARSET_FAMILY
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB)
jpayne@69: # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
jpayne@69: #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__)
jpayne@69: # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
jpayne@69: #else
jpayne@69: # define U_CHARSET_FAMILY U_ASCII_FAMILY
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_CHARSET_IS_UTF8
jpayne@69: *
jpayne@69: * Hardcode the default charset to UTF-8.
jpayne@69: *
jpayne@69: * If this is set to 1, then
jpayne@69: * - ICU will assume that all non-invariant char*, StringPiece, std::string etc.
jpayne@69: * contain UTF-8 text, regardless of what the system API uses
jpayne@69: * - some ICU code will use fast functions like u_strFromUTF8()
jpayne@69: * rather than the more general and more heavy-weight conversion API (ucnv.h)
jpayne@69: * - ucnv_getDefaultName() always returns "UTF-8"
jpayne@69: * - ucnv_setDefaultName() is disabled and will not change the default charset
jpayne@69: * - static builds of ICU are smaller
jpayne@69: * - more functionality is available with the UCONFIG_NO_CONVERSION build-time
jpayne@69: * configuration option (see unicode/uconfig.h)
jpayne@69: * - the UCONFIG_NO_CONVERSION build option in uconfig.h is more usable
jpayne@69: *
jpayne@69: * @stable ICU 4.2
jpayne@69: * @see UCONFIG_NO_CONVERSION
jpayne@69: */
jpayne@69: #ifdef U_CHARSET_IS_UTF8
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif U_PLATFORM_IS_LINUX_BASED || U_PLATFORM_IS_DARWIN_BASED || \
jpayne@69: U_PLATFORM == U_PF_EMSCRIPTEN
jpayne@69: # define U_CHARSET_IS_UTF8 1
jpayne@69: #else
jpayne@69: # define U_CHARSET_IS_UTF8 0
jpayne@69: #endif
jpayne@69:
jpayne@69: /** @} */
jpayne@69:
jpayne@69: /*===========================================================================*/
jpayne@69: /** @{ Information about wchar support */
jpayne@69: /*===========================================================================*/
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_HAVE_WCHAR_H
jpayne@69: * Indicates whether is available (1) or not (0). Set to 1 by default.
jpayne@69: *
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: #ifdef U_HAVE_WCHAR_H
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9
jpayne@69: /*
jpayne@69: * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.
jpayne@69: * The type and header existed, but the library functions did not work as expected.
jpayne@69: * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway.
jpayne@69: */
jpayne@69: # define U_HAVE_WCHAR_H 0
jpayne@69: #else
jpayne@69: # define U_HAVE_WCHAR_H 1
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_SIZEOF_WCHAR_T
jpayne@69: * U_SIZEOF_WCHAR_T==sizeof(wchar_t)
jpayne@69: *
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: #ifdef U_SIZEOF_WCHAR_T
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9)
jpayne@69: /*
jpayne@69: * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.
jpayne@69: * Newer Mac OS X has size 4.
jpayne@69: */
jpayne@69: # define U_SIZEOF_WCHAR_T 1
jpayne@69: #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN
jpayne@69: # define U_SIZEOF_WCHAR_T 2
jpayne@69: #elif U_PLATFORM == U_PF_AIX
jpayne@69: /*
jpayne@69: * AIX 6.1 information, section "Wide character data representation":
jpayne@69: * "... the wchar_t datatype is 32-bit in the 64-bit environment and
jpayne@69: * 16-bit in the 32-bit environment."
jpayne@69: * and
jpayne@69: * "All locales use Unicode for their wide character code values (process code),
jpayne@69: * except the IBM-eucTW codeset."
jpayne@69: */
jpayne@69: # ifdef __64BIT__
jpayne@69: # define U_SIZEOF_WCHAR_T 4
jpayne@69: # else
jpayne@69: # define U_SIZEOF_WCHAR_T 2
jpayne@69: # endif
jpayne@69: #elif U_PLATFORM == U_PF_OS390
jpayne@69: /*
jpayne@69: * z/OS V1R11 information center, section "LP64 | ILP32":
jpayne@69: * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.
jpayne@69: * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes."
jpayne@69: */
jpayne@69: # ifdef _LP64
jpayne@69: # define U_SIZEOF_WCHAR_T 4
jpayne@69: # else
jpayne@69: # define U_SIZEOF_WCHAR_T 2
jpayne@69: # endif
jpayne@69: #elif U_PLATFORM == U_PF_OS400
jpayne@69: # if defined(__UTF32__)
jpayne@69: /*
jpayne@69: * LOCALETYPE(*LOCALEUTF) is specified.
jpayne@69: * Wide-character strings are in UTF-32,
jpayne@69: * narrow-character strings are in UTF-8.
jpayne@69: */
jpayne@69: # define U_SIZEOF_WCHAR_T 4
jpayne@69: # elif defined(__UCS2__)
jpayne@69: /*
jpayne@69: * LOCALETYPE(*LOCALEUCS2) is specified.
jpayne@69: * Wide-character strings are in UCS-2,
jpayne@69: * narrow-character strings are in EBCDIC.
jpayne@69: */
jpayne@69: # define U_SIZEOF_WCHAR_T 2
jpayne@69: # else
jpayne@69: /*
jpayne@69: * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.
jpayne@69: * Wide-character strings are in 16-bit EBCDIC,
jpayne@69: * narrow-character strings are in EBCDIC.
jpayne@69: */
jpayne@69: # define U_SIZEOF_WCHAR_T 2
jpayne@69: # endif
jpayne@69: #else
jpayne@69: # define U_SIZEOF_WCHAR_T 4
jpayne@69: #endif
jpayne@69:
jpayne@69: #ifndef U_HAVE_WCSCPY
jpayne@69: #define U_HAVE_WCSCPY U_HAVE_WCHAR_H
jpayne@69: #endif
jpayne@69:
jpayne@69: /** @} */
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_HAVE_CHAR16_T
jpayne@69: * Defines whether the char16_t type is available for UTF-16
jpayne@69: * and u"abc" UTF-16 string literals are supported.
jpayne@69: * This is a new standard type and standard string literal syntax in C++0x
jpayne@69: * but has been available in some compilers before.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_HAVE_CHAR16_T
jpayne@69: /* Use the predefined value. */
jpayne@69: #else
jpayne@69: /*
jpayne@69: * Notes:
jpayne@69: * Visual Studio 2010 (_MSC_VER==1600) defines char16_t as a typedef
jpayne@69: * and does not support u"abc" string literals.
jpayne@69: * Visual Studio 2015 (_MSC_VER>=1900) and above adds support for
jpayne@69: * both char16_t and u"abc" string literals.
jpayne@69: * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but
jpayne@69: * does not support u"abc" string literals.
jpayne@69: * C++11 and C11 require support for UTF-16 literals
jpayne@69: * TODO: Fix for plain C. Doesn't work on Mac.
jpayne@69: */
jpayne@69: # if U_CPLUSPLUS_VERSION >= 11 || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
jpayne@69: # define U_HAVE_CHAR16_T 1
jpayne@69: # else
jpayne@69: # define U_HAVE_CHAR16_T 0
jpayne@69: # endif
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * @{
jpayne@69: * \def U_DECLARE_UTF16
jpayne@69: * Do not use this macro because it is not defined on all platforms.
jpayne@69: * Use the UNICODE_STRING or U_STRING_DECL macros instead.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #ifdef U_DECLARE_UTF16
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif U_HAVE_CHAR16_T \
jpayne@69: || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
jpayne@69: || (defined(__HP_aCC) && __HP_aCC >= 035000) \
jpayne@69: || (defined(__HP_cc) && __HP_cc >= 111106) \
jpayne@69: || (defined(U_IN_DOXYGEN))
jpayne@69: # define U_DECLARE_UTF16(string) u ## string
jpayne@69: #elif U_SIZEOF_WCHAR_T == 2 \
jpayne@69: && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))
jpayne@69: # define U_DECLARE_UTF16(string) L ## string
jpayne@69: #else
jpayne@69: /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */
jpayne@69: #endif
jpayne@69:
jpayne@69: /** @} */
jpayne@69:
jpayne@69: /*===========================================================================*/
jpayne@69: /** @{ Symbol import-export control */
jpayne@69: /*===========================================================================*/
jpayne@69:
jpayne@69: #ifdef U_EXPORT
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif defined(U_STATIC_IMPLEMENTATION)
jpayne@69: # define U_EXPORT
jpayne@69: #elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(dllexport) && \
jpayne@69: UPRV_HAS_DECLSPEC_ATTRIBUTE(dllimport))
jpayne@69: # define U_EXPORT __declspec(dllexport)
jpayne@69: #elif defined(__GNUC__)
jpayne@69: # define U_EXPORT __attribute__((visibility("default")))
jpayne@69: #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
jpayne@69: || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
jpayne@69: # define U_EXPORT __global
jpayne@69: /*#elif defined(__HP_aCC) || defined(__HP_cc)
jpayne@69: # define U_EXPORT __declspec(dllexport)*/
jpayne@69: #else
jpayne@69: # define U_EXPORT
jpayne@69: #endif
jpayne@69:
jpayne@69: /* U_CALLCONV is related to U_EXPORT2 */
jpayne@69: #ifdef U_EXPORT2
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif defined(_MSC_VER)
jpayne@69: # define U_EXPORT2 __cdecl
jpayne@69: #else
jpayne@69: # define U_EXPORT2
jpayne@69: #endif
jpayne@69:
jpayne@69: #ifdef U_IMPORT
jpayne@69: /* Use the predefined value. */
jpayne@69: #elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(dllexport) && \
jpayne@69: UPRV_HAS_DECLSPEC_ATTRIBUTE(dllimport))
jpayne@69: /* Windows needs to export/import data. */
jpayne@69: # define U_IMPORT __declspec(dllimport)
jpayne@69: #else
jpayne@69: # define U_IMPORT
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_CALLCONV
jpayne@69: * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary
jpayne@69: * in callback function typedefs to make sure that the calling convention
jpayne@69: * is compatible.
jpayne@69: *
jpayne@69: * This is only used for non-ICU-API functions.
jpayne@69: * When a function is a public ICU API,
jpayne@69: * you must use the U_CAPI and U_EXPORT2 qualifiers.
jpayne@69: *
jpayne@69: * Please note, you need to use U_CALLCONV after the *.
jpayne@69: *
jpayne@69: * NO : "static const char U_CALLCONV *func( . . . )"
jpayne@69: * YES: "static const char* U_CALLCONV func( . . . )"
jpayne@69: *
jpayne@69: * @stable ICU 2.0
jpayne@69: */
jpayne@69: #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
jpayne@69: # define U_CALLCONV __cdecl
jpayne@69: #else
jpayne@69: # define U_CALLCONV U_EXPORT2
jpayne@69: #endif
jpayne@69:
jpayne@69: /**
jpayne@69: * \def U_CALLCONV_FPTR
jpayne@69: * Similar to U_CALLCONV, but only used on function pointers.
jpayne@69: * @internal
jpayne@69: */
jpayne@69: #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
jpayne@69: # define U_CALLCONV_FPTR U_CALLCONV
jpayne@69: #else
jpayne@69: # define U_CALLCONV_FPTR
jpayne@69: #endif
jpayne@69: /* @} */
jpayne@69:
jpayne@69: #endif // _PLATFORM_H