DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
5.3KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any purpose with
  6. * or without fee is hereby granted, provided that the above copyright notice and this
  7. * permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
  10. * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
  11. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  12. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
  13. * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef DISTRHO_DEFINES_H_INCLUDED
  17. #define DISTRHO_DEFINES_H_INCLUDED
  18. /* Compatibility with non-clang compilers */
  19. #ifndef __has_feature
  20. # define __has_feature(x) 0
  21. #endif
  22. #ifndef __has_extension
  23. # define __has_extension __has_feature
  24. #endif
  25. /* Check OS */
  26. #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
  27. # define DISTRHO_PLUGIN_EXPORT extern "C" __declspec (dllexport)
  28. # define DISTRHO_OS_WINDOWS 1
  29. # define DISTRHO_DLL_EXTENSION "dll"
  30. #else
  31. # define DISTRHO_PLUGIN_EXPORT extern "C" __attribute__ ((visibility("default")))
  32. # if defined(__APPLE__)
  33. # define DISTRHO_OS_MAC 1
  34. # define DISTRHO_DLL_EXTENSION "dylib"
  35. # elif defined(__HAIKU__)
  36. # define DISTRHO_OS_HAIKU 1
  37. # elif defined(__linux__) || defined(__linux)
  38. # define DISTRHO_OS_LINUX 1
  39. # endif
  40. #endif
  41. #ifndef DISTRHO_DLL_EXTENSION
  42. # define DISTRHO_DLL_EXTENSION "so"
  43. #endif
  44. /* Check for C++11 support */
  45. #if defined(HAVE_CPP11_SUPPORT)
  46. # if HAVE_CPP11_SUPPORT
  47. # define DISTRHO_PROPER_CPP11_SUPPORT
  48. # endif
  49. #elif __cplusplus >= 201103L || (defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405) || __has_extension(cxx_noexcept)
  50. # define DISTRHO_PROPER_CPP11_SUPPORT
  51. # if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407 && ! defined(__clang__)) || (defined(__clang__) && ! __has_extension(cxx_override_control))
  52. # define override // gcc4.7+ only
  53. # define final // gcc4.7+ only
  54. # endif
  55. #endif
  56. #ifndef DISTRHO_PROPER_CPP11_SUPPORT
  57. # define noexcept throw()
  58. # define override
  59. # define final
  60. # define nullptr NULL
  61. #endif
  62. /* Define DISTRHO_SAFE_ASSERT* */
  63. #define DISTRHO_SAFE_ASSERT(cond) if (! (cond)) d_safe_assert(#cond, __FILE__, __LINE__);
  64. #define DISTRHO_SAFE_ASSERT_BREAK(cond) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); break; }
  65. #define DISTRHO_SAFE_ASSERT_CONTINUE(cond) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); continue; }
  66. #define DISTRHO_SAFE_ASSERT_RETURN(cond, ret) if (! (cond)) { d_safe_assert(#cond, __FILE__, __LINE__); return ret; }
  67. /* Define DISTRHO_SAFE_EXCEPTION */
  68. #define DISTRHO_SAFE_EXCEPTION(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); }
  69. #define DISTRHO_SAFE_EXCEPTION_BREAK(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); break; }
  70. #define DISTRHO_SAFE_EXCEPTION_CONTINUE(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); continue; }
  71. #define DISTRHO_SAFE_EXCEPTION_RETURN(msg, ret) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); return ret; }
  72. /* Define DISTRHO_DECLARE_NON_COPY_CLASS */
  73. #ifdef DISTRHO_PROPER_CPP11_SUPPORT
  74. # define DISTRHO_DECLARE_NON_COPY_CLASS(ClassName) \
  75. private: \
  76. ClassName(ClassName&) = delete; \
  77. ClassName(const ClassName&) = delete; \
  78. ClassName& operator=(ClassName&) = delete ; \
  79. ClassName& operator=(const ClassName&) = delete;
  80. #else
  81. # define DISTRHO_DECLARE_NON_COPY_CLASS(ClassName) \
  82. private: \
  83. ClassName(ClassName&); \
  84. ClassName(const ClassName&); \
  85. ClassName& operator=(ClassName&); \
  86. ClassName& operator=(const ClassName&);
  87. #endif
  88. /* Define DISTRHO_DECLARE_NON_COPY_STRUCT */
  89. #ifdef DISTRHO_PROPER_CPP11_SUPPORT
  90. # define DISTRHO_DECLARE_NON_COPY_STRUCT(StructName) \
  91. StructName(StructName&) = delete; \
  92. StructName(const StructName&) = delete; \
  93. StructName& operator=(StructName&) = delete; \
  94. StructName& operator=(const StructName&) = delete;
  95. #else
  96. # define DISTRHO_DECLARE_NON_COPY_STRUCT(StructName)
  97. #endif
  98. /* Define DISTRHO_PREVENT_HEAP_ALLOCATION */
  99. #ifdef DISTRHO_PROPER_CPP11_SUPPORT
  100. # define DISTRHO_PREVENT_HEAP_ALLOCATION \
  101. private: \
  102. static void* operator new(size_t) = delete; \
  103. static void operator delete(void*) = delete;
  104. #else
  105. # define DISTRHO_PREVENT_HEAP_ALLOCATION \
  106. private: \
  107. static void* operator new(size_t); \
  108. static void operator delete(void*);
  109. #endif
  110. /* Define namespace */
  111. #ifndef DISTRHO_NAMESPACE
  112. # define DISTRHO_NAMESPACE DISTRHO
  113. #endif
  114. #define START_NAMESPACE_DISTRHO namespace DISTRHO_NAMESPACE {
  115. #define END_NAMESPACE_DISTRHO }
  116. #define USE_NAMESPACE_DISTRHO using namespace DISTRHO_NAMESPACE;
  117. /* Useful typedefs */
  118. typedef unsigned char uchar;
  119. typedef unsigned short int ushort;
  120. typedef unsigned int uint;
  121. typedef unsigned long int ulong;
  122. #endif // DISTRHO_DEFINES_H_INCLUDED