You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ov_common_defines.h 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #pragma once
  2. #include <cstdlib> // For Unix Compatibility (size_t)
  3. #include <cstdint> // For Uint standard
  4. //
  5. // This file checks the presence of several defines that are supposed to
  6. // be set by the build system. In addition, it defines some additional ones.
  7. //
  8. #if defined(_MSC_VER)
  9. // We need some magic to get #warning behavior on MSVC
  10. #define STRINGISE(N) #N
  11. #define EXPAND_THEN_STRINGISE(N) STRINGISE(N)
  12. #define __LINE_STR__ EXPAND_THEN_STRINGISE(__LINE__)
  13. // Format #pragma message
  14. #define __LOC__ __FILE__ "(" __LINE_STR__ ")"
  15. #define __OUTPUT_FORMAT__(type) __LOC__ " : " type " : "
  16. // Actual warning message type
  17. #define __WARNING__ __OUTPUT_FORMAT__("Warning")
  18. #endif
  19. //___________________________________________________________________//
  20. // //
  21. // Operating System identification //
  22. //___________________________________________________________________//
  23. // //
  24. #if !(defined(TARGET_OS_Windows) || defined(TARGET_OS_Linux) || defined(TARGET_OS_MacOS))
  25. #if defined(_MSC_VER)
  26. #pragma message( __WARNING__ "No known target OS specified!")
  27. #else
  28. #warning "No known target OS specified!"
  29. #endif
  30. #endif
  31. //___________________________________________________________________//
  32. // //
  33. // Build type identification //
  34. //___________________________________________________________________//
  35. // //
  36. #if !(defined(TARGET_BUILDTYPE_Debug) || defined(TARGET_BUILDTYPE_Release))
  37. #if defined(_MSC_VER)
  38. #pragma message( __WARNING__ "No known build type defined!")
  39. #else
  40. #warning "No known build type defined!"
  41. #endif
  42. #endif
  43. //___________________________________________________________________//
  44. // //
  45. // Compiler software identification //
  46. //___________________________________________________________________//
  47. // //
  48. #if !(defined(TARGET_COMPILER_GCC) || defined(TARGET_COMPILER_VisualStudio) || defined(TARGET_COMPILER_LLVM))
  49. #if defined(_MSC_VER)
  50. #pragma message( __WARNING__ "No known compiler defined!")
  51. #else
  52. #warning "No known compiler defined!"
  53. #endif
  54. #endif
  55. //___________________________________________________________________//
  56. // //
  57. // API Definition //
  58. //___________________________________________________________________//
  59. // //
  60. // Taken from
  61. // - http://people.redhat.com/drepper/dsohowto.pdf
  62. // - http://www.nedprod.com/programs/gccvisibility.html
  63. #if defined OV_Shared
  64. #if defined TARGET_OS_Windows
  65. #define OV_API_Export __declspec(dllexport)
  66. #define OV_API_Import __declspec(dllimport)
  67. #elif defined TARGET_OS_Linux || defined TARGET_OS_MacOS
  68. #define OV_API_Export __attribute__((visibility("default")))
  69. #define OV_API_Import __attribute__((visibility("default")))
  70. #else
  71. #define OV_API_Export
  72. #define OV_API_Import
  73. #endif
  74. #else
  75. #define OV_API_Export
  76. #define OV_API_Import
  77. #endif
  78. #if defined OV_Exports
  79. #define OV_API OV_API_Export
  80. #else
  81. #define OV_API OV_API_Import
  82. #endif
  83. //___________________________________________________________________//
  84. // //
  85. // API Definition for plugins //
  86. //___________________________________________________________________//
  87. // //
  88. // Taken from
  89. // - http://people.redhat.com/drepper/dsohowto.pdf
  90. // - http://www.nedprod.com/programs/gccvisibility.html
  91. #if defined OVP_Shared
  92. #if defined TARGET_OS_Windows
  93. #define OVP_API_Export __declspec(dllexport)
  94. #define OVP_API_Import __declspec(dllimport)
  95. #elif defined TARGET_OS_Linux || defined TARGET_OS_MacOS
  96. #define OVP_API_Export __attribute__((visibility("default")))
  97. #define OPV_API_Import __attribute__((visibility("default")))
  98. #else
  99. #define OVP_API_Export
  100. #define OVP_API_Import
  101. #endif
  102. #else
  103. # define OVP_API_Export
  104. # define OVP_API_Import
  105. #endif
  106. #if defined OVP_Exports
  107. # define OVP_API OVP_API_Export
  108. #else
  109. # define OVP_API OVP_API_Import
  110. #endif
  111. //___________________________________________________________________//
  112. // //
  113. // NULL Definition //
  114. //___________________________________________________________________//
  115. // //
  116. #ifndef NULL
  117. #define NULL 0
  118. #endif
  119. #if defined(__cplusplus) && (__cplusplus >= 201402L)
  120. #define OV_DEPRECATED(since) [[deprecated("Since " #since)]]
  121. #define OV_DEPRECATED_FOR(since, replacement) [[deprecated("Since " #since "; use " #replacement)]]
  122. #elif defined(_MSC_VER)
  123. #define OV_DEPRECATED(since) __declspec(deprecated("Since " # since))
  124. #define OV_DEPRECATED_FOR(since, replacement) __declspec(deprecated("Since " #since "; use " #replacement))
  125. #else
  126. #define OV_DEPRECATED(since) __attribute__((__deprecated__))
  127. #define OV_DEPRECATED_FOR(since, replacement) __attribute__((__deprecated__))
  128. #endif