BsPlatformDefines.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. // Initial platform/compiler-related stuff to set.
  5. #define BS_PLATFORM_WIN32 1
  6. #define BS_PLATFORM_LINUX 2
  7. #define BS_PLATFORM_OSX 3
  8. #define BS_PLATFORM_IOS 4
  9. #define BS_PLATFORM_ANDROID 5
  10. #define BS_COMPILER_MSVC 1
  11. #define BS_COMPILER_GNUC 2
  12. #define BS_COMPILER_INTEL 3
  13. #define BS_COMPILER_CLANG 4
  14. #define BS_ARCHITECTURE_x86_32 1
  15. #define BS_ARCHITECTURE_x86_64 2
  16. #define BS_ENDIAN_LITTLE 1
  17. #define BS_ENDIAN_BIG 2
  18. #define BS_ENDIAN BS_ENDIAN_LITTLE
  19. // Finds the compiler type and version.
  20. #if defined(__clang__)
  21. # define BS_COMPILER BS_COMPILER_CLANG
  22. # define BS_COMP_VER __clang_version__
  23. # define BS_THREADLOCAL __thread
  24. # define BS_STDCALL __attribute__((stdcall))
  25. # define BS_CDECL __attribute__((cdecl))
  26. #elif defined(__GNUC__) // Check after Clang, as Clang defines this too
  27. # define BS_COMPILER BS_COMPILER_GNUC
  28. # define BS_COMP_VER (((__GNUC__)*100) + \
  29. (__GNUC_MINOR__*10) + \
  30. __GNUC_PATCHLEVEL__)
  31. # define BS_THREADLOCAL __thread
  32. # define BS_STDCALL __attribute__((stdcall))
  33. # define BS_CDECL __attribute__((cdecl))
  34. #elif defined (__INTEL_COMPILER)
  35. # define BS_COMPILER BS_COMPILER_INTEL
  36. # define BS_COMP_VER __INTEL_COMPILER
  37. # define BS_STDCALL __stdcall
  38. # define BS_CDECL __cdecl
  39. // BS_THREADLOCAL define is down below because Intel compiler defines it differently based on platform
  40. #elif defined(_MSC_VER) // Check after Clang and Intel, since we could be building with either within VS
  41. # define BS_COMPILER BS_COMPILER_MSVC
  42. # define BS_COMP_VER _MSC_VER
  43. # define BS_THREADLOCAL __declspec(thread)
  44. # define BS_STDCALL __stdcall
  45. # define BS_CDECL __cdecl
  46. # undef __PRETTY_FUNCTION__
  47. # define __PRETTY_FUNCTION__ __FUNCSIG__
  48. #else
  49. # pragma error "No known compiler. "
  50. #endif
  51. // Finds the current platform
  52. #if defined( __WIN32__ ) || defined( _WIN32 )
  53. # define BS_PLATFORM BS_PLATFORM_WIN32
  54. #elif defined( __APPLE_CC__)
  55. # define BS_PLATFORM BS_PLATFORM_OSX
  56. #else
  57. # define BS_PLATFORM BS_PLATFORM_LINUX
  58. #endif
  59. // Find the architecture type
  60. #if defined(__x86_64__) || defined(_M_X64)
  61. # define BS_ARCH_TYPE BS_ARCHITECTURE_x86_64
  62. #else
  63. # define BS_ARCH_TYPE BS_ARCHITECTURE_x86_32
  64. #endif
  65. // DLL export
  66. #if BS_PLATFORM == BS_PLATFORM_WIN32 // Windows
  67. # if BS_COMPILER == BS_COMPILER_MSVC
  68. # if defined(BS_STATIC_LIB)
  69. # define BS_UTILITY_EXPORT
  70. # else
  71. # if defined(BS_UTILITY_EXPORTS)
  72. # define BS_UTILITY_EXPORT __declspec(dllexport)
  73. # else
  74. # define BS_UTILITY_EXPORT __declspec(dllimport)
  75. # endif
  76. # endif
  77. # else
  78. # if defined(BS_STATIC_LIB)
  79. # define BS_UTILITY_EXPORT
  80. # else
  81. # if defined(BS_UTILITY_EXPORTS)
  82. # define BS_UTILITY_EXPORT __attribute__ ((dllexport))
  83. # else
  84. # define BS_UTILITY_EXPORT __attribute__ ((dllimport))
  85. # endif
  86. # endif
  87. # endif
  88. # define BS_UTILITY_HIDDEN
  89. #else // Linux/Mac settings
  90. # define BS_UTILITY_EXPORT __attribute__ ((visibility ("default")))
  91. # define BS_UTILITY_HIDDEN __attribute__ ((visibility ("hidden")))
  92. #endif
  93. // DLL export for plugins
  94. #if BS_PLATFORM == BS_PLATFORM_WIN32 // Windows
  95. # if BS_COMPILER == BS_COMPILER_MSVC
  96. # define BS_PLUGIN_EXPORT __declspec(dllexport)
  97. # else
  98. # define BS_PLUGIN_EXPORT __attribute__ ((dllexport))
  99. # endif
  100. # define BS_UTILITY_HIDDEN
  101. #else // Linux/Mac settings
  102. # define BS_PLUGIN_EXPORT __attribute__ ((visibility ("default")))
  103. #endif
  104. // Windows Settings
  105. #if BS_PLATFORM == BS_PLATFORM_WIN32
  106. // Win32 compilers use _DEBUG for specifying debug builds.
  107. // for MinGW, we set DEBUG
  108. # if defined(_DEBUG) || defined(DEBUG)
  109. # define BS_DEBUG_MODE 1
  110. # else
  111. # define BS_DEBUG_MODE 0
  112. # endif
  113. # if BS_COMPILER == BS_COMPILER_INTEL
  114. # define BS_THREADLOCAL __declspec(thread)
  115. # endif
  116. #endif
  117. // Linux/Mac Settings
  118. #if BS_PLATFORM == BS_PLATFORM_LINUX || BS_PLATFORM == BS_PLATFORM_OSX
  119. # ifdef DEBUG
  120. # define BS_DEBUG_MODE 1
  121. # else
  122. # define BS_DEBUG_MODE 0
  123. # endif
  124. # if BS_COMPILER == BS_COMPILER_INTEL
  125. # define BS_THREADLOCAL __thread
  126. # endif
  127. #endif