hexport.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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_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. // DEPRECATED
  18. #if defined(__GNUC__) || defined(__clang__)
  19. #define DEPRECATED __attribute__((visibility("deprecated")))
  20. #define UNUSED __attribute__((visibility("unused")))
  21. #else
  22. #define DEPRECATED
  23. #define UNUSED(v) ((void)(v))
  24. #endif
  25. // @param[IN | OUT | INOUT]
  26. #ifndef IN
  27. #define IN
  28. #endif
  29. #ifndef OUT
  30. #define OUT
  31. #endif
  32. #ifndef INOUT
  33. #define INOUT
  34. #endif
  35. // @field[OPTIONAL | REQUIRED | REPEATED]
  36. #ifndef OPTIONAL
  37. #define OPTIONAL
  38. #endif
  39. #ifndef REQUIRED
  40. #define REQUIRED
  41. #endif
  42. #ifndef REPEATED
  43. #define REPEATED
  44. #endif
  45. #ifdef __cplusplus
  46. #ifndef EXTERN_C
  47. #define EXTERN_C extern "C"
  48. #endif
  49. #ifndef BEGIN_EXTERN_C
  50. #define BEGIN_EXTERN_C extern "C" {
  51. #endif
  52. #ifndef END_EXTERN_C
  53. #define END_EXTERN_C } // extern "C"
  54. #endif
  55. #ifndef BEGIN_NAMESPACE
  56. #define BEGIN_NAMESPACE(ns) namespace ns {
  57. #endif
  58. #ifndef END_NAMESPACE
  59. #define END_NAMESPACE(ns) } // namespace ns
  60. #endif
  61. #ifndef USING_NAMESPACE
  62. #define USING_NAMESPACE(ns) using namespace ns;
  63. #endif
  64. #ifndef DEFAULT
  65. #define DEFAULT(x) = x
  66. #endif
  67. #ifndef ENUM
  68. #define ENUM(e) enum e
  69. #endif
  70. #ifndef STRUCT
  71. #define STRUCT(s) struct s
  72. #endif
  73. #else
  74. #define EXTERN_C extern
  75. #define BEGIN_EXTERN_C
  76. #define END_EXTERN_C
  77. #define BEGIN_NAMESPACE(ns)
  78. #define END_NAMESPACE(ns)
  79. #define USING_NAMESPACE(ns)
  80. #ifndef DEFAULT
  81. #define DEFAULT(x)
  82. #endif
  83. #ifndef ENUM
  84. #define ENUM(e)\
  85. typedef enum e e;\
  86. enum e
  87. #endif
  88. #ifndef STRUCT
  89. #define STRUCT(s)\
  90. typedef struct s s;\
  91. struct s
  92. #endif
  93. #endif // __cplusplus
  94. #define BEGIN_NAMESPACE_HV BEGIN_NAMESPACE(hv)
  95. #define END_NAMESPACE_HV END_NAMESPACE(hv)
  96. #define USING_NAMESPACE_HV USING_NAMESPACE(hv)
  97. #endif // HV_EXPORT_H_