expat_external.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
  2. See the file COPYING for copying permission.
  3. */
  4. #ifndef Expat_External_INCLUDED
  5. #define Expat_External_INCLUDED 1
  6. /* External API definitions */
  7. #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
  8. #define XML_USE_MSC_EXTENSIONS 1
  9. #endif
  10. /* Expat tries very hard to make the API boundary very specifically
  11. defined. There are two macros defined to control this boundary;
  12. each of these can be defined before including this header to
  13. achieve some different behavior, but doing so it not recommended or
  14. tested frequently.
  15. XMLCALL - The calling convention to use for all calls across the
  16. "library boundary." This will default to cdecl, and
  17. try really hard to tell the compiler that's what we
  18. want.
  19. XMLIMPORT - Whatever magic is needed to note that a function is
  20. to be imported from a dynamically loaded library
  21. (.dll, .so, or .sl, depending on your platform).
  22. The XMLCALL macro was added in Expat 1.95.7. The only one which is
  23. expected to be directly useful in client code is XMLCALL.
  24. Note that on at least some Unix versions, the Expat library must be
  25. compiled with the cdecl calling convention as the default since
  26. system headers may assume the cdecl convention.
  27. */
  28. #ifndef XMLCALL
  29. #if defined(_MSC_VER)
  30. #define XMLCALL __cdecl
  31. #elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
  32. #define XMLCALL __attribute__((cdecl))
  33. #else
  34. /* For any platform which uses this definition and supports more than
  35. one calling convention, we need to extend this definition to
  36. declare the convention used on that platform, if it's possible to
  37. do so.
  38. If this is the case for your platform, please file a bug report
  39. with information on how to identify your platform via the C
  40. pre-processor and how to specify the same calling convention as the
  41. platform's malloc() implementation.
  42. */
  43. #define XMLCALL
  44. #endif
  45. #endif /* not defined XMLCALL */
  46. #if !defined(XML_STATIC) && !defined(XMLIMPORT)
  47. #ifndef XML_BUILDING_EXPAT
  48. /* using Expat from an application */
  49. #ifdef XML_USE_MSC_EXTENSIONS
  50. #define XMLIMPORT __declspec(dllimport)
  51. #endif
  52. #endif
  53. #endif /* not defined XML_STATIC */
  54. #if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4)
  55. #define XMLIMPORT __attribute__ ((visibility ("default")))
  56. #endif
  57. /* If we didn't define it above, define it away: */
  58. #ifndef XMLIMPORT
  59. #define XMLIMPORT
  60. #endif
  61. #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
  62. #define XML_ATTR_MALLOC __attribute__((__malloc__))
  63. #else
  64. #define XML_ATTR_MALLOC
  65. #endif
  66. #if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
  67. #define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
  68. #else
  69. #define XML_ATTR_ALLOC_SIZE(x)
  70. #endif
  71. #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
  72. #ifdef __cplusplus
  73. extern "C" {
  74. #endif
  75. #ifdef XML_UNICODE_WCHAR_T
  76. # define XML_UNICODE
  77. # if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2)
  78. # error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc"
  79. # endif
  80. #endif
  81. #ifdef XML_UNICODE /* Information is UTF-16 encoded. */
  82. #ifdef XML_UNICODE_WCHAR_T
  83. typedef wchar_t XML_Char;
  84. typedef wchar_t XML_LChar;
  85. #else
  86. typedef unsigned short XML_Char;
  87. typedef char XML_LChar;
  88. #endif /* XML_UNICODE_WCHAR_T */
  89. #else /* Information is UTF-8 encoded. */
  90. typedef char XML_Char;
  91. typedef char XML_LChar;
  92. #endif /* XML_UNICODE */
  93. #ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
  94. #if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
  95. typedef __int64 XML_Index;
  96. typedef unsigned __int64 XML_Size;
  97. #else
  98. typedef long long XML_Index;
  99. typedef unsigned long long XML_Size;
  100. #endif
  101. #else
  102. typedef long XML_Index;
  103. typedef unsigned long XML_Size;
  104. #endif /* XML_LARGE_SIZE */
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif /* not Expat_External_INCLUDED */