BsPlatformDefines.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. #define BS_EDITOR_BUILD 1
  20. // Finds the compiler type and version.
  21. #if defined(__clang__)
  22. # define BS_COMPILER BS_COMPILER_CLANG
  23. # define BS_COMP_VER __clang_version__
  24. # define BS_THREADLOCAL __thread
  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. #elif defined (__INTEL_COMPILER)
  32. # define BS_COMPILER BS_COMPILER_INTEL
  33. # define BS_COMP_VER __INTEL_COMPILER
  34. // BS_THREADLOCAL define is down below because Intel compiler defines it differently based on platform
  35. #elif defined(_MSC_VER) // Check after Clang and Intel, since we could be building with either within VS
  36. # define BS_COMPILER BS_COMPILER_MSVC
  37. # define BS_COMP_VER _MSC_VER
  38. # define BS_THREADLOCAL __declspec(thread)
  39. # undef __PRETTY_FUNCTION__
  40. # define __PRETTY_FUNCTION__ __FUNCSIG__
  41. #else
  42. # pragma error "No known compiler. "
  43. #endif
  44. // Finds the current platform
  45. #if defined( __WIN32__ ) || defined( _WIN32 )
  46. # define BS_PLATFORM BS_PLATFORM_WIN32
  47. #elif defined( __APPLE_CC__)
  48. # define BS_PLATFORM BS_PLATFORM_OSX
  49. #else
  50. # define BS_PLATFORM BS_PLATFORM_LINUX
  51. #endif
  52. // Find the architecture type
  53. #if defined(__x86_64__) || defined(_M_X64)
  54. # define BS_ARCH_TYPE BS_ARCHITECTURE_x86_64
  55. #else
  56. # define BS_ARCH_TYPE BS_ARCHITECTURE_x86_32
  57. #endif
  58. // Windows Settings
  59. #if BS_PLATFORM == BS_PLATFORM_WIN32
  60. // If we're not including this from a client build, specify that the stuff
  61. // should get exported. Otherwise, import it.
  62. # if defined( BS_STATIC_LIB )
  63. // Linux compilers don't have symbol import/export directives.
  64. # define BS_UTILITY_EXPORT
  65. # else
  66. # if defined(BS_UTILITY_EXPORTS)
  67. # define BS_UTILITY_EXPORT __declspec( dllexport )
  68. # else
  69. # if defined( __MINGW32__ )
  70. # define BS_UTILITY_EXPORT
  71. # else
  72. # define BS_UTILITY_EXPORT __declspec( dllimport )
  73. # endif
  74. # endif
  75. # endif
  76. // Win32 compilers use _DEBUG for specifying debug builds.
  77. // for MinGW, we set DEBUG
  78. # if defined(_DEBUG) || defined(DEBUG)
  79. # define BS_DEBUG_MODE 1
  80. # else
  81. # define BS_DEBUG_MODE 0
  82. # endif
  83. # if BS_COMPILER == BS_COMPILER_INTEL
  84. # define BS_THREADLOCAL __declspec(thread)
  85. # endif
  86. #endif // BS_PLATFORM == BS_PLATFORM_WIN32
  87. // Linux/Apple Settings
  88. #if BS_PLATFORM == BS_PLATFORM_LINUX || BS_PLATFORM == BS_PLATFORM_OSX
  89. // Enable GCC symbol visibility
  90. # if defined( BS_GCC_VISIBILITY )
  91. # define BS_UTILITY_EXPORT __attribute__ ((visibility("default")))
  92. # else
  93. # define BS_UTILITY_EXPORT
  94. # endif
  95. # ifdef DEBUG
  96. # define BS_DEBUG_MODE 1
  97. # else
  98. # define BS_DEBUG_MODE 0
  99. # endif
  100. # if BS_COMPILER == BS_COMPILER_INTEL
  101. # define BS_THREADLOCAL __thread
  102. # endif
  103. #endif