hexport.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #ifndef HV_EXPORT_H_
  2. #define HV_EXPORT_H_
  3. // HV_EXPORT
  4. #if defined(HV_STATICLIB) || defined(HV_SOURCE)
  5. #define HV_EXPORT
  6. #elif defined(_MSC_VER)
  7. #if defined(HV_DYNAMICLIB) || defined(HV_EXPORTS) || defined(hv_EXPORTS)
  8. #define HV_EXPORT __declspec(dllexport)
  9. #else
  10. #define HV_EXPORT __declspec(dllimport)
  11. #endif
  12. #elif defined(__GNUC__)
  13. #define HV_EXPORT __attribute__((visibility("default")))
  14. #else
  15. #define HV_EXPORT
  16. #endif
  17. // HV_INLINE
  18. #define HV_INLINE static inline
  19. // HV_DEPRECATED
  20. #if defined(HV_NO_DEPRECATED)
  21. #define HV_DEPRECATED
  22. #elif defined(__GNUC__) || defined(__clang__)
  23. #define HV_DEPRECATED __attribute__((deprecated))
  24. #elif defined(_MSC_VER)
  25. #define HV_DEPRECATED __declspec(deprecated)
  26. #else
  27. #define HV_DEPRECATED
  28. #endif
  29. // HV_UNUSED
  30. #if defined(__GNUC__)
  31. #define HV_UNUSED __attribute__((visibility("unused")))
  32. #else
  33. #define HV_UNUSED
  34. #endif
  35. // @param[IN | OUT | INOUT]
  36. #ifndef IN
  37. #define IN
  38. #endif
  39. #ifndef OUT
  40. #define OUT
  41. #endif
  42. #ifndef INOUT
  43. #define INOUT
  44. #endif
  45. // @field[OPTIONAL | REQUIRED | REPEATED]
  46. #ifndef OPTIONAL
  47. #define OPTIONAL
  48. #endif
  49. #ifndef REQUIRED
  50. #define REQUIRED
  51. #endif
  52. #ifndef REPEATED
  53. #define REPEATED
  54. #endif
  55. #ifdef __cplusplus
  56. #ifndef EXTERN_C
  57. #define EXTERN_C extern "C"
  58. #endif
  59. #ifndef BEGIN_EXTERN_C
  60. #define BEGIN_EXTERN_C extern "C" {
  61. #endif
  62. #ifndef END_EXTERN_C
  63. #define END_EXTERN_C } // extern "C"
  64. #endif
  65. #ifndef BEGIN_NAMESPACE
  66. #define BEGIN_NAMESPACE(ns) namespace ns {
  67. #endif
  68. #ifndef END_NAMESPACE
  69. #define END_NAMESPACE(ns) } // namespace ns
  70. #endif
  71. #ifndef USING_NAMESPACE
  72. #define USING_NAMESPACE(ns) using namespace ns;
  73. #endif
  74. #ifndef DEFAULT
  75. #define DEFAULT(x) = x
  76. #endif
  77. #ifndef ENUM
  78. #define ENUM(e) enum e
  79. #endif
  80. #ifndef STRUCT
  81. #define STRUCT(s) struct s
  82. #endif
  83. #else
  84. #define EXTERN_C extern
  85. #define BEGIN_EXTERN_C
  86. #define END_EXTERN_C
  87. #define BEGIN_NAMESPACE(ns)
  88. #define END_NAMESPACE(ns)
  89. #define USING_NAMESPACE(ns)
  90. #ifndef DEFAULT
  91. #define DEFAULT(x)
  92. #endif
  93. #ifndef ENUM
  94. #define ENUM(e)\
  95. typedef enum e e;\
  96. enum e
  97. #endif
  98. #ifndef STRUCT
  99. #define STRUCT(s)\
  100. typedef struct s s;\
  101. struct s
  102. #endif
  103. #endif // __cplusplus
  104. #define BEGIN_NAMESPACE_HV BEGIN_NAMESPACE(hv)
  105. #define END_NAMESPACE_HV END_NAMESPACE(hv)
  106. #define USING_NAMESPACE_HV USING_NAMESPACE(hv)
  107. // MSVC ports
  108. #ifdef _MSC_VER
  109. #pragma warning (disable: 4251) // STL dll
  110. #pragma warning (disable: 4275) // dll-interface
  111. #if _MSC_VER < 1900 // < VS2015
  112. #ifndef __cplusplus
  113. #ifndef inline
  114. #define inline __inline
  115. #endif
  116. #endif
  117. #ifndef snprintf
  118. #define snprintf _snprintf
  119. #endif
  120. #endif
  121. #endif
  122. #endif // HV_EXPORT_H_