17#ifndef DISTRHO_DEFINES_H_INCLUDED
18#define DISTRHO_DEFINES_H_INCLUDED
22# define __has_feature(x) 0
24#ifndef __has_extension
25# define __has_extension __has_feature
29#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
31# define DISTRHO_PLUGIN_EXPORT extern "C" __declspec (dllexport)
32# define DISTRHO_OS_WINDOWS 1
33# define DISTRHO_DLL_EXTENSION "dll"
36# define DISTRHO_PLUGIN_EXPORT extern "C" __attribute__ ((visibility("default")))
37# if defined(__APPLE__)
38# define DISTRHO_OS_MAC 1
39# define DISTRHO_DLL_EXTENSION "dylib"
40# elif defined(__HAIKU__)
41# define DISTRHO_OS_HAIKU 1
42# elif defined(__linux__) || defined(__linux)
43# define DISTRHO_OS_LINUX 1
44# elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
45# define DISTRHO_OS_BSD 1
46# elif defined(__GNU__)
47# define DISTRHO_OS_GNU_HURD 1
48# elif defined(__EMSCRIPTEN__)
49# define DISTRHO_OS_WASM 1
53#ifndef DISTRHO_DLL_EXTENSION
54# define DISTRHO_DLL_EXTENSION "so"
58#if defined(HAVE_CPP11_SUPPORT)
59# if HAVE_CPP11_SUPPORT
60# define DISTRHO_PROPER_CPP11_SUPPORT
62#elif __cplusplus >= 201103L || (defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405) || __has_extension(cxx_noexcept) || (defined(_MSC_VER) && _MSVC_LANG >= 201103L)
63# define DISTRHO_PROPER_CPP11_SUPPORT
64# if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407 && ! defined(__clang__)) || (defined(__clang__) && ! __has_extension(cxx_override_control))
70#ifndef DISTRHO_PROPER_CPP11_SUPPORT
72# define noexcept throw()
80# define unlikely(x) __builtin_expect(x,0)
86#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 480
87# define DISTRHO_DEPRECATED __attribute__((deprecated))
88#elif defined(_MSC_VER)
89# define DISTRHO_DEPRECATED [[deprecated]]
91# define DISTRHO_DEPRECATED
95#if defined(__clang__) && (__clang_major__ * 100 + __clang_minor__) >= 502
96# define DISTRHO_DEPRECATED_BY(other) __attribute__((deprecated("", other)))
97#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
98# define DISTRHO_DEPRECATED_BY(other) __attribute__((deprecated("Use " other)))
100# define DISTRHO_DEPRECATED_BY(other) DISTRHO_DEPRECATED
104#define DISTRHO_SAFE_ASSERT(cond) if (unlikely(!(cond))) d_safe_assert (#cond, __FILE__, __LINE__);
105#define DISTRHO_SAFE_ASSERT_INT(cond, value) if (unlikely(!(cond))) d_safe_assert_int (#cond, __FILE__, __LINE__, static_cast<int>(value));
106#define DISTRHO_SAFE_ASSERT_INT2(cond, v1, v2) if (unlikely(!(cond))) d_safe_assert_int2 (#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2));
107#define DISTRHO_SAFE_ASSERT_UINT(cond, value) if (unlikely(!(cond))) d_safe_assert_uint (#cond, __FILE__, __LINE__, static_cast<uint>(value));
108#define DISTRHO_SAFE_ASSERT_UINT2(cond, v1, v2) if (unlikely(!(cond))) d_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2));
110#define DISTRHO_SAFE_ASSERT_BREAK(cond) if (unlikely(!(cond))) { d_safe_assert(#cond, __FILE__, __LINE__); break; }
111#define DISTRHO_SAFE_ASSERT_CONTINUE(cond) if (unlikely(!(cond))) { d_safe_assert(#cond, __FILE__, __LINE__); continue; }
112#define DISTRHO_SAFE_ASSERT_RETURN(cond, ret) if (unlikely(!(cond))) { d_safe_assert(#cond, __FILE__, __LINE__); return ret; }
114#define DISTRHO_CUSTOM_SAFE_ASSERT(msg, cond) if (unlikely(!(cond))) d_custom_safe_assert(msg, #cond, __FILE__, __LINE__);
115#define DISTRHO_CUSTOM_SAFE_ASSERT_BREAK(msg, cond) if (unlikely(!(cond))) { d_custom_safe_assert(msg, #cond, __FILE__, __LINE__); break; }
116#define DISTRHO_CUSTOM_SAFE_ASSERT_CONTINUE(msg, cond) if (unlikely(!(cond))) { d_custom_safe_assert(msg, #cond, __FILE__, __LINE__); continue; }
117#define DISTRHO_CUSTOM_SAFE_ASSERT_RETURN(msg, cond, ret) if (unlikely(!(cond))) { d_custom_safe_assert(msg, #cond, __FILE__, __LINE__); return ret; }
119#define DISTRHO_CUSTOM_SAFE_ASSERT_ONCE_BREAK(msg, cond) if (unlikely(!(cond))) { static bool _p; if (!_p) { _p = true; d_custom_safe_assert(msg, #cond, __FILE__, __LINE__); } break; }
120#define DISTRHO_CUSTOM_SAFE_ASSERT_ONCE_CONTINUE(msg, cond) if (unlikely(!(cond))) { static bool _p; if (!_p) { _p = true; d_custom_safe_assert(msg, #cond, __FILE__, __LINE__); } continue; }
121#define DISTRHO_CUSTOM_SAFE_ASSERT_ONCE_RETURN(msg, cond, ret) if (unlikely(!(cond))) { static bool _p; if (!_p) { _p = true; d_custom_safe_assert(msg, #cond, __FILE__, __LINE__); } return ret; }
123#define DISTRHO_SAFE_ASSERT_INT_BREAK(cond, value) if (unlikely(!(cond))) { d_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value)); break; }
124#define DISTRHO_SAFE_ASSERT_INT_CONTINUE(cond, value) if (unlikely(!(cond))) { d_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value)); continue; }
125#define DISTRHO_SAFE_ASSERT_INT_RETURN(cond, value, ret) if (unlikely(!(cond))) { d_safe_assert_int(#cond, __FILE__, __LINE__, static_cast<int>(value)); return ret; }
127#define DISTRHO_SAFE_ASSERT_INT2_BREAK(cond, v1, v2) if (unlikely(!(cond))) { d_safe_assert_int2(#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2)); break; }
128#define DISTRHO_SAFE_ASSERT_INT2_CONTINUE(cond, v1, v2) if (unlikely(!(cond))) { d_safe_assert_int2(#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2)); continue; }
129#define DISTRHO_SAFE_ASSERT_INT2_RETURN(cond, v1, v2, ret) if (unlikely(!(cond))) { d_safe_assert_int2(#cond, __FILE__, __LINE__, static_cast<int>(v1), static_cast<int>(v2)); return ret; }
131#define DISTRHO_SAFE_ASSERT_UINT_BREAK(cond, value) if (unlikely(!(cond))) { d_safe_assert_uint(#cond, __FILE__, __LINE__, static_cast<uint>(value)); break; }
132#define DISTRHO_SAFE_ASSERT_UINT_CONTINUE(cond, value) if (unlikely(!(cond))) { d_safe_assert_uint(#cond, __FILE__, __LINE__, static_cast<uint>(value)); continue; }
133#define DISTRHO_SAFE_ASSERT_UINT_RETURN(cond, value, ret) if (unlikely(!(cond))) { d_safe_assert_uint(#cond, __FILE__, __LINE__, static_cast<uint>(value)); return ret; }
135#define DISTRHO_SAFE_ASSERT_UINT2_BREAK(cond, v1, v2) if (unlikely(!(cond))) { d_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2)); break; }
136#define DISTRHO_SAFE_ASSERT_UINT2_CONTINUE(cond, v1, v2) if (unlikely(!(cond))) { d_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2)); continue; }
137#define DISTRHO_SAFE_ASSERT_UINT2_RETURN(cond, v1, v2, ret) if (unlikely(!(cond))) { d_safe_assert_uint2(#cond, __FILE__, __LINE__, static_cast<uint>(v1), static_cast<uint>(v2)); return ret; }
140#define DISTRHO_SAFE_EXCEPTION(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); }
141#define DISTRHO_SAFE_EXCEPTION_BREAK(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); break; }
142#define DISTRHO_SAFE_EXCEPTION_CONTINUE(msg) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); continue; }
143#define DISTRHO_SAFE_EXCEPTION_RETURN(msg, ret) catch(...) { d_safe_exception(msg, __FILE__, __LINE__); return ret; }
146#ifdef DISTRHO_PROPER_CPP11_SUPPORT
147# define DISTRHO_DECLARE_NON_COPYABLE(ClassName) \
149 ClassName(ClassName&) = delete; \
150 ClassName(const ClassName&) = delete; \
151 ClassName& operator=(ClassName&) = delete; \
152 ClassName& operator=(const ClassName&) = delete;
154# define DISTRHO_DECLARE_NON_COPYABLE(ClassName) \
156 ClassName(ClassName&); \
157 ClassName(const ClassName&); \
158 ClassName& operator=(ClassName&); \
159 ClassName& operator=(const ClassName&);
163#ifdef DISTRHO_PROPER_CPP11_SUPPORT
164# define DISTRHO_PREVENT_HEAP_ALLOCATION \
166 static void* operator new(size_t) = delete; \
167 static void operator delete(void*) = delete;
169# define DISTRHO_PREVENT_HEAP_ALLOCATION \
171 static void* operator new(size_t); \
172 static void operator delete(void*);
176#ifdef DISTRHO_PROPER_CPP11_SUPPORT
177# define DISTRHO_PREVENT_VIRTUAL_HEAP_ALLOCATION \
179 static void* operator new(std::size_t) = delete;
181# define DISTRHO_PREVENT_VIRTUAL_HEAP_ALLOCATION \
183 static void* operator new(std::size_t);
187#ifndef DISTRHO_NAMESPACE
188# define DISTRHO_NAMESPACE DISTRHO
190#define START_NAMESPACE_DISTRHO namespace DISTRHO_NAMESPACE {
191#define END_NAMESPACE_DISTRHO }
192#define USE_NAMESPACE_DISTRHO using namespace DISTRHO_NAMESPACE;
195#ifdef DISTRHO_OS_WINDOWS
196# define DISTRHO_OS_SEP '\\'
197# define DISTRHO_OS_SEP_STR "\\"
198# define DISTRHO_OS_SPLIT ';'
199# define DISTRHO_OS_SPLIT_STR ";"
201# define DISTRHO_OS_SEP '/'
202# define DISTRHO_OS_SEP_STR "/"
203# define DISTRHO_OS_SPLIT ':'
204# define DISTRHO_OS_SPLIT_STR ":"
209# define strdup _strdup
210# pragma warning(disable:4244)
214#define ARRAY_SIZE(ARRAY) sizeof(ARRAY)/sizeof(ARRAY[0])
217typedef unsigned char uchar;
218typedef unsigned short int ushort;
219typedef unsigned int uint;
220typedef unsigned long int ulong;
224#define DISTRHO_DECLARE_NON_COPY_CLASS(ClassName) DISTRHO_DECLARE_NON_COPYABLE(ClassName)
225#define DISTRHO_DECLARE_NON_COPY_STRUCT(StructName) DISTRHO_DECLARE_NON_COPYABLE(StructName)
unsigned long long int ulonglong
Definition CarlaDefines.h:329
unsigned short int ushort
Definition CarlaDefines.h:326
unsigned char uchar
Definition CarlaDefines.h:325
unsigned int uint
Definition CarlaDefines.h:327
unsigned long int ulong
Definition CarlaDefines.h:328