hexport.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. #ifdef __cplusplus
  36. #ifndef EXTERN_C
  37. #define EXTERN_C extern "C"
  38. #endif
  39. #ifndef BEGIN_EXTERN_C
  40. #define BEGIN_EXTERN_C extern "C" {
  41. #endif
  42. #ifndef END_EXTERN_C
  43. #define END_EXTERN_C } // extern "C"
  44. #endif
  45. #ifndef BEGIN_NAMESPACE
  46. #define BEGIN_NAMESPACE(ns) namespace ns {
  47. #endif
  48. #ifndef END_NAMESPACE
  49. #define END_NAMESPACE(ns) } // namespace ns
  50. #endif
  51. #ifndef USING_NAMESPACE
  52. #define USING_NAMESPACE(ns) using namespace ns;
  53. #endif
  54. #ifndef DEFAULT
  55. #define DEFAULT(x) = x
  56. #endif
  57. #ifndef ENUM
  58. #define ENUM(e) enum e
  59. #endif
  60. #ifndef STRUCT
  61. #define STRUCT(s) struct s
  62. #endif
  63. #else
  64. #define EXTERN_C extern
  65. #define BEGIN_EXTERN_C
  66. #define END_EXTERN_C
  67. #define BEGIN_NAMESPACE(ns)
  68. #define END_NAMESPACE(ns)
  69. #define USING_NAMESPACE(ns)
  70. #ifndef DEFAULT
  71. #define DEFAULT(x)
  72. #endif
  73. #ifndef ENUM
  74. #define ENUM(e)\
  75. typedef enum e e;\
  76. enum e
  77. #endif
  78. #ifndef STRUCT
  79. #define STRUCT(s)\
  80. typedef struct s s;\
  81. struct s
  82. #endif
  83. #endif // __cplusplus
  84. #define BEGIN_NAMESPACE_HV BEGIN_NAMESPACE(hv)
  85. #define END_NAMESPACE_HV END_NAMESPACE(hv)
  86. #define USING_NAMESPACE_HV USING_NAMESPACE(hv)
  87. // MSVC ports
  88. #ifdef _MSC_VER
  89. #pragma warning (disable: 4251) // STL dll
  90. #pragma warning (disable: 4275) // dll-interface
  91. #if _MSC_VER < 1900 // < VS2015
  92. #ifndef __cplusplus
  93. #ifndef inline
  94. #define inline __inline
  95. #endif
  96. #endif
  97. #ifndef snprintf
  98. #define snprintf _snprintf
  99. #endif
  100. #endif
  101. #endif
  102. #endif // HV_EXPORT_H_