Platform.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2008-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: Thomas Koeller
  6. //-----------------------------------------------------------------------------
  7. /** \file
  8. \brief Provides platform-specific defines
  9. */
  10. #if !defined(PYLON_PLATFORM_H)
  11. #define PYLON_PLATFORM_H
  12. #if defined (_MSC_VER) && defined (_WIN32)
  13. // Platform Microsoft windows, Microsoft tool chain
  14. /** \brief Is defined, when using the pylon for Windows API */
  15. # define PYLON_WIN_BUILD // we are building for windows
  16. # define PYLON_HAS_AVI_SUPPORT
  17. # define PYLON_HAS_MALLOC_H
  18. // define PYLON_XX_BUILD to distinguish between 32 & 64 bit builds
  19. # if defined(_WIN32) && !defined(_WIN64)
  20. # define PYLON_32_BUILD
  21. # elif defined(_WIN32) && defined(_WIN64)
  22. # define PYLON_64_BUILD
  23. # else
  24. # error unsupported wordsize (32/64 platform)
  25. # endif
  26. # if defined(PYLON_STATIC)
  27. # define APIEXPORT
  28. # define APIIMPORT
  29. # define PUBLIC_INTERFACE
  30. # else
  31. # define APIEXPORT __declspec(dllexport)
  32. # define APIIMPORT __declspec(dllimport)
  33. # define PUBLIC_INTERFACE
  34. # endif
  35. # if !defined(CDECL)
  36. # define CDECL
  37. # endif
  38. # if defined PYLON_NO_DEPRECATE
  39. # define PYLON_DEPRECATED(x)
  40. # else
  41. # if _MSC_VER >= 1400
  42. # define PYLON_DEPRECATED(x) __declspec(deprecated(x))
  43. # else
  44. # define PYLON_DEPRECATED(x) __declspec(deprecated)
  45. # endif
  46. # endif
  47. // packing used for pylon structs/classes
  48. # define PYLON_PACKING 8
  49. #elif (defined(__GNUC__) && defined(__linux__)) || defined(__APPLE__)
  50. // Platform Linux, gcc or Darwin, llvm toolchain
  51. #ifdef __APPLE__
  52. // Platform Darwin / OS X
  53. # define PYLON_OSX_BUILD
  54. # define PYLON_HAS_BYTEORDER
  55. #else
  56. # define PYLON_LINUX_BUILD
  57. // Platform Linux
  58. # define PYLON_HAS_MALLOC_H
  59. # define PYLON_HAS_BYTESWAP
  60. # define PYLON_HAS_THREADCAP
  61. #endif
  62. /** \brief Is defined when using the pylon for Unix API (Linux & Darwin / OS X */
  63. # define PYLON_UNIX_BUILD
  64. # define PYLON_HAS_POSIX_THREADS
  65. //TODO this works only on a C99 compiler. We must ensure, that things like SIZE_MAX UINTPTR_MAX are always defined
  66. #if !defined(__STDC_LIMIT_MACROS)
  67. # define __STDC_LIMIT_MACROS
  68. #endif
  69. #if !defined(__STDC_CONSTANT_MACROS)
  70. # define __STDC_CONSTANT_MACROS
  71. #endif
  72. #if !defined(__STDC_FORMAT_MACROS)
  73. # define __STDC_FORMAT_MACROS // for PRI* in inttypes.h
  74. #endif
  75. # include <pylon/api_autoconf.h>
  76. # include <stdint.h>
  77. // gnu compiler needs explicit visibility of interfaces, so dynamic_cast works
  78. # define PUBLIC_INTERFACE APIEXPORT
  79. // define PYLON_XX_BUILD to distinguish between 32 & 64 bit builds
  80. // __WORDSIZE is not always defined and sometimes set to 32 on 64 bit platforms. So we prefer other sources.
  81. # if __GNUC__
  82. # if __x86_64__ || __ppc64__ || __powerpc64__ || __aarch64__
  83. # define PYLON_64_BUILD
  84. # else
  85. # define PYLON_32_BUILD
  86. # endif
  87. # else
  88. // Fallback to the unsafe wordsize method
  89. # if __WORDSIZE == 32
  90. # define PYLON_32_BUILD
  91. # elif __WORDSIZE == 64
  92. # define PYLON_64_BUILD
  93. # else
  94. # error unsupported wordsize (32/64 platform)
  95. # endif
  96. # endif
  97. // packing used for pylon structs/classes
  98. # define PYLON_PACKING 8
  99. #else
  100. # error Unsupported platform
  101. #endif
  102. // Architecture
  103. #if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(_M_ARM) || defined(_M_ARMT) || defined(__arm) || defined(__aarch64__) || defined(_M_ARM64)
  104. # define PYLON_ARM_BUILD
  105. #endif
  106. #if defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(_M_I86) || defined(_M_IX86) || defined(_X86_) || defined(__X86__) || defined(__I86__) || defined(_M_AMD64) || defined(_M_X64)
  107. # define PYLON_INTEL_BUILD
  108. #endif
  109. // The GENICAM_BUILD define has been removed in GenICam 3.0.
  110. #if defined(GENICAM_BUILD) && defined(PYLON_WIN_BUILD)
  111. #pragma message("The GENICAM_BUILD define has been deprecated and can therefore be removed.")
  112. #endif
  113. // Check whether the GenICam header (GCLinkage.h) has been included before this one as this leads to wrong DLL suffixes in debug builds.
  114. #if defined(LINKAGE_H) && defined(PYLON_WIN_BUILD) && !defined(GENICAM_NO_AUTO_IMPLIB) && !defined(GENICAM_USER_ALWAYS_LINK_RELEASE) && (defined(_DEBUG) || defined(DEBUG)) && !defined(PYLON_BUILD_DEBUG)
  115. #error You must include pylon/Platform.h (or at least define GENICAM_USER_ALWAYS_LINK_RELEASE) before including any GenICam headers. Note: If you include only pylon/PylonIncludes.h this will be done automatically.
  116. #endif
  117. // Turn off GenICam compiler warning about untested compiler.
  118. #if !defined(GENICAM_USER_ACCEPTS_ANY_COMPILER)
  119. # define GENICAM_USER_ACCEPTS_ANY_COMPILER
  120. #endif
  121. // Macro for deprecated classes in pylon 6.0
  122. #if defined(PYLON_6_0_NO_DEPRECATE) || defined(PYLON_UNIX_BUILD)
  123. # define PYLON_6_0_DEPRECATED(message)
  124. #else
  125. # define PYLON_6_0_DEPRECATED(message) PYLON_DEPRECATED(message)
  126. #endif
  127. #endif /* !defined(PYLON_PLATFORM_H) */