hexport.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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_DEPRECATED
  18. #if defined(HV_NO_DEPRECATED)
  19. #define HV_DEPRECATED
  20. #elif defined(__GNUC__) || defined(__clang__)
  21. #define HV_DEPRECATED __attribute__((deprecated))
  22. #elif defined(_MSC_VER)
  23. #define HV_DEPRECATED __declspec(deprecated)
  24. #else
  25. #define HV_DEPRECATED
  26. #endif
  27. // HV_UNUSED
  28. #if defined(__GNUC__)
  29. #define HV_UNUSED __attribute__((visibility("unused")))
  30. #else
  31. #define HV_UNUSED
  32. #endif
  33. // @param[IN | OUT | INOUT]
  34. #ifndef IN
  35. #define IN
  36. #endif
  37. #ifndef OUT
  38. #define OUT
  39. #endif
  40. #ifndef INOUT
  41. #define INOUT
  42. #endif
  43. // @field[OPTIONAL | REQUIRED | REPEATED]
  44. #ifndef OPTIONAL
  45. #define OPTIONAL
  46. #endif
  47. #ifndef REQUIRED
  48. #define REQUIRED
  49. #endif
  50. #ifndef REPEATED
  51. #define REPEATED
  52. #endif
  53. #ifdef __cplusplus
  54. #ifndef EXTERN_C
  55. #define EXTERN_C extern "C"
  56. #endif
  57. #ifndef BEGIN_EXTERN_C
  58. #define BEGIN_EXTERN_C extern "C" {
  59. #endif
  60. #ifndef END_EXTERN_C
  61. #define END_EXTERN_C } // extern "C"
  62. #endif
  63. #ifndef BEGIN_NAMESPACE
  64. #define BEGIN_NAMESPACE(ns) namespace ns {
  65. #endif
  66. #ifndef END_NAMESPACE
  67. #define END_NAMESPACE(ns) } // namespace ns
  68. #endif
  69. #ifndef USING_NAMESPACE
  70. #define USING_NAMESPACE(ns) using namespace ns;
  71. #endif
  72. #ifndef DEFAULT
  73. #define DEFAULT(x) = x
  74. #endif
  75. #ifndef ENUM
  76. #define ENUM(e) enum e
  77. #endif
  78. #ifndef STRUCT
  79. #define STRUCT(s) struct s
  80. #endif
  81. #else
  82. #define EXTERN_C extern
  83. #define BEGIN_EXTERN_C
  84. #define END_EXTERN_C
  85. #define BEGIN_NAMESPACE(ns)
  86. #define END_NAMESPACE(ns)
  87. #define USING_NAMESPACE(ns)
  88. #ifndef DEFAULT
  89. #define DEFAULT(x)
  90. #endif
  91. #ifndef ENUM
  92. #define ENUM(e)\
  93. typedef enum e e;\
  94. enum e
  95. #endif
  96. #ifndef STRUCT
  97. #define STRUCT(s)\
  98. typedef struct s s;\
  99. struct s
  100. #endif
  101. #endif // __cplusplus
  102. #define BEGIN_NAMESPACE_HV BEGIN_NAMESPACE(hv)
  103. #define END_NAMESPACE_HV END_NAMESPACE(hv)
  104. #define USING_NAMESPACE_HV USING_NAMESPACE(hv)
  105. // MSVC ports
  106. #ifdef _MSC_VER
  107. #if _MSC_VER < 1900 // < VS2015
  108. #ifndef __cplusplus
  109. #ifndef inline
  110. #define inline __inline
  111. #endif
  112. #endif
  113. #ifndef snprintf
  114. #define snprintf _snprintf
  115. #endif
  116. #endif
  117. #endif
  118. #endif // HV_EXPORT_H_