BsPlatformDefines.h 3.5 KB

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