hexport.h 2.0 KB

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