BsPlatformDefines.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. #elif defined(__GNUC__) // Check after Clang, as Clang defines this too
  26. # define BS_COMPILER BS_COMPILER_GNUC
  27. # define BS_COMP_VER (((__GNUC__)*100) + \
  28. (__GNUC_MINOR__*10) + \
  29. __GNUC_PATCHLEVEL__)
  30. # define BS_THREADLOCAL __thread
  31. # define BS_STDCALL __attribute__((stdcall))
  32. #elif defined (__INTEL_COMPILER)
  33. # define BS_COMPILER BS_COMPILER_INTEL
  34. # define BS_COMP_VER __INTEL_COMPILER
  35. # define BS_STDCALL __stdcall
  36. // BS_THREADLOCAL define is down below because Intel compiler defines it differently based on platform
  37. #elif defined(_MSC_VER) // Check after Clang and Intel, since we could be building with either within VS
  38. # define BS_COMPILER BS_COMPILER_MSVC
  39. # define BS_COMP_VER _MSC_VER
  40. # define BS_THREADLOCAL __declspec(thread)
  41. # define BS_STDCALL __stdcall
  42. # undef __PRETTY_FUNCTION__
  43. # define __PRETTY_FUNCTION__ __FUNCSIG__
  44. #else
  45. # pragma error "No known compiler. "
  46. #endif
  47. // Finds the current platform
  48. #if defined( __WIN32__ ) || defined( _WIN32 )
  49. # define BS_PLATFORM BS_PLATFORM_WIN32
  50. #elif defined( __APPLE_CC__)
  51. # define BS_PLATFORM BS_PLATFORM_OSX
  52. #else
  53. # define BS_PLATFORM BS_PLATFORM_LINUX
  54. #endif
  55. // Find the architecture type
  56. #if defined(__x86_64__) || defined(_M_X64)
  57. # define BS_ARCH_TYPE BS_ARCHITECTURE_x86_64
  58. #else
  59. # define BS_ARCH_TYPE BS_ARCHITECTURE_x86_32
  60. #endif
  61. // DLL export
  62. #if BS_PLATFORM == BS_PLATFORM_WIN32 // Windows
  63. # if BS_COMPILER == BS_COMPILER_MSVC
  64. # if defined(BS_STATIC_LIB)
  65. # define BS_UTILITY_EXPORT
  66. # else
  67. # if defined(BS_UTILITY_EXPORTS)
  68. # define BS_UTILITY_EXPORT __declspec(dllexport)
  69. # else
  70. # define BS_UTILITY_EXPORT __declspec(dllimport)
  71. # endif
  72. # endif
  73. # else
  74. # if defined(BS_STATIC_LIB)
  75. # define BS_UTILITY_EXPORT
  76. # else
  77. # if defined(BS_UTILITY_EXPORTS)
  78. # define BS_UTILITY_EXPORT __attribute__ ((dllexport))
  79. # else
  80. # define BS_UTILITY_EXPORT __attribute__ ((dllimport))
  81. # endif
  82. # endif
  83. # endif
  84. # define BS_UTILITY_HIDDEN
  85. #else // Linux/Mac settings
  86. # define BS_UTILITY_EXPORT __attribute__ ((visibility ("default")))
  87. # define BS_UTILITY_HIDDEN __attribute__ ((visibility ("hidden")))
  88. #endif
  89. // DLL export for plugins
  90. #if BS_PLATFORM == BS_PLATFORM_WIN32 // Windows
  91. # if BS_COMPILER == BS_COMPILER_MSVC
  92. # define BS_PLUGIN_EXPORT __declspec(dllexport)
  93. # else
  94. # define BS_PLUGIN_EXPORT __attribute__ ((dllexport))
  95. # endif
  96. # define BS_UTILITY_HIDDEN
  97. #else // Linux/Mac settings
  98. # define BS_PLUGIN_EXPORT __attribute__ ((visibility ("default")))
  99. #endif
  100. // Windows Settings
  101. #if BS_PLATFORM == BS_PLATFORM_WIN32
  102. // Win32 compilers use _DEBUG for specifying debug builds.
  103. // for MinGW, we set DEBUG
  104. # if defined(_DEBUG) || defined(DEBUG)
  105. # define BS_DEBUG_MODE 1
  106. # else
  107. # define BS_DEBUG_MODE 0
  108. # endif
  109. # if BS_COMPILER == BS_COMPILER_INTEL
  110. # define BS_THREADLOCAL __declspec(thread)
  111. # endif
  112. #endif
  113. // Linux/Mac Settings
  114. #if BS_PLATFORM == BS_PLATFORM_LINUX || BS_PLATFORM == BS_PLATFORM_OSX
  115. # ifdef DEBUG
  116. # define BS_DEBUG_MODE 1
  117. # else
  118. # define BS_DEBUG_MODE 0
  119. # endif
  120. # if BS_COMPILER == BS_COMPILER_INTEL
  121. # define BS_THREADLOCAL __thread
  122. # endif
  123. #endif