stdinclude.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2006-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: Hartmut Nebelung
  6. //-----------------------------------------------------------------------------
  7. /*!
  8. \file
  9. \brief standard definitions
  10. */
  11. #ifndef __STDINCLUDE_H__
  12. #define __STDINCLUDE_H__
  13. #include <assert.h>
  14. #include <pylon/Platform.h>
  15. #ifdef _MSC_VER
  16. # pragma pack(push, PYLON_PACKING)
  17. #endif /* _MSC_VER */
  18. #ifdef PYLON_WIN_BUILD
  19. # include <objbase.h> // for definition of type 'interface'
  20. #endif
  21. ///////////////////////////////////////////////////////////////////////////////
  22. // Note:
  23. ///////////////////////////////////////////////////////////////////////////////
  24. // The PY_ macros are only for backward compatibility
  25. // please use the PYLON_ macros instead. Thank you!
  26. ///////////////////////////////////////////////////////////////////////////////
  27. // mark a variable as unused. This prevents unused parameter / unused local variable warnings on warning level 4.
  28. #define PYLON_UNUSED(unused_var) ((void)(unused_var))
  29. #define PY_UNUSED(unused_var) PYLON_UNUSED(unused_var)
  30. // returns the number of elements in an array
  31. #define PYLON_COUNTOF(arr) (sizeof(arr)/sizeof(*arr))
  32. #define PY_COUNTOF(arr) PYLON_COUNTOF(arr)
  33. // PY_ASSERT works like normal assertion
  34. #define PYLON_ASSERT(cond) assert(cond)
  35. #define PY_ASSERT(cond) PYLON_ASSERT(cond)
  36. // PY_ASSERT2 works like a normal assertion but can be passed a descriptive text string
  37. #define PYLON_ASSERT2(cond, tx) assert((cond) && tx)
  38. #define PY_ASSERT2(cond, tx) PYLON_ASSERT2(cond, tx)
  39. // verify macro
  40. #ifndef NDEBUG
  41. // assert in debug builds but do not remove in release builds
  42. # define PYLON_VERIFY(cond) PYLON_ASSERT(cond)
  43. # define PY_VERIFY(cond) PYLON_ASSERT(cond)
  44. // assert in debug builds but do not remove in release builds but can be passed a descriptive text string
  45. # define PYLON_VERIFY2(cond, tx) PYLON_ASSERT2(cond, tx)
  46. # define PY_VERIFY2(cond, tx) PYLON_ASSERT2(cond, tx)
  47. #else
  48. # define PYLON_VERIFY(cond) ((void)(cond))
  49. # define PY_VERIFY(cond) ((void)(cond))
  50. # define PYLON_VERIFY2(cond, tx) PYLON_VERIFY(cond)
  51. # define PY_VERIFY2(cond, tx) PYLON_VERIFY(cond)
  52. #endif
  53. #if defined(PYLON_WIN_BUILD)
  54. # if defined(PYLON_32_BUILD)
  55. # define PYLON_UNALIGNED
  56. # elif defined(PYLON_64_BUILD)
  57. # define PYLON_UNALIGNED __unaligned
  58. # endif
  59. #elif defined(PYLON_UNIX_BUILD)
  60. # define PYLON_UNALIGNED
  61. #else
  62. # error Invalid platform
  63. #endif
  64. // Attention in MSVC this is a string literal
  65. // but under gnuc this is a local variable!
  66. #if defined(_MSC_VER) && _MSC_VER >= 1300
  67. // Attention this does not behave like a string literal! Use it as a variable of type const char[]
  68. # define PYLON_FUNC __FUNCTION__
  69. #elif defined(__GNUC__)
  70. // Attention this does not behave like a string literal! Use it as a variable of type const char[]
  71. # define PYLON_FUNC __func__
  72. #else
  73. // Attention this does not behave like a string literal! Use it as a variable of type const char[]
  74. # define PYLON_FUNC "sorry_funcname_na"
  75. #endif
  76. // namespace aliases
  77. #include <Base/GCNamespace.h>
  78. #include <GenApi/GenApiNamespace.h>
  79. #include <pylon/TypeMappings.h> // for String_t, StringList_t
  80. namespace Pylon
  81. {
  82. /// Pylon's string definition
  83. typedef GenICam::gcstring String_t;
  84. /// Pylon's string list definition
  85. typedef GenICam::gcstring_vector StringList_t;
  86. }
  87. #ifdef _MSC_VER
  88. # pragma pack(pop)
  89. #endif /* _MSC_VER */
  90. #endif //__STDINCLUDE_H__