Loading...
Searching...
No Matches
juce_PlatformDefs.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
The code included in this file is provided under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
To use, copy, modify, and/or distribute this software for any purpose with or
without fee is hereby granted provided that the above copyright notice and
this permission notice appear in all copies.
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
#pragma once
namespace juce
{
//==============================================================================
/* This file defines miscellaneous macros for debugging, assertions, etc.
*/
//==============================================================================
#ifdef JUCE_FORCE_DEBUG
#undef JUCE_DEBUG
#if JUCE_FORCE_DEBUG
#define JUCE_DEBUG 1
#endif
#endif
#if JUCE_WINDOWS
#define JUCE_CALLTYPE __stdcall
#define JUCE_CDECL __cdecl
#else
#define JUCE_CALLTYPE
#define JUCE_CDECL
#endif
//==============================================================================
// Debugging and assertion macros
#ifndef JUCE_LOG_CURRENT_ASSERTION
#if JUCE_LOG_ASSERTIONS || JUCE_DEBUG
#define JUCE_LOG_CURRENT_ASSERTION juce::logAssertion (__FILE__, __LINE__);
#else
#define JUCE_LOG_CURRENT_ASSERTION
#endif
#endif
//==============================================================================
#if JUCE_IOS || JUCE_LINUX || JUCE_BSD
#define JUCE_BREAK_IN_DEBUGGER { ::kill (0, SIGTRAP); }
#elif JUCE_MSVC
#ifndef __INTEL_COMPILER
#pragma intrinsic (__debugbreak)
#endif
#define JUCE_BREAK_IN_DEBUGGER { __debugbreak(); }
#elif JUCE_INTEL && (JUCE_GCC || JUCE_CLANG || JUCE_MAC)
#if JUCE_NO_INLINE_ASM
#define JUCE_BREAK_IN_DEBUGGER { }
#else
#define JUCE_BREAK_IN_DEBUGGER { asm ("int $3"); }
#endif
#elif JUCE_ARM && JUCE_MAC
#define JUCE_BREAK_IN_DEBUGGER { __builtin_debugtrap(); }
#elif JUCE_ANDROID
#define JUCE_BREAK_IN_DEBUGGER { __builtin_trap(); }
#else
#define JUCE_BREAK_IN_DEBUGGER { __asm int 3 }
#endif
#if JUCE_CLANG && defined (__has_feature) && ! defined (JUCE_ANALYZER_NORETURN)
#if __has_feature (attribute_analyzer_noreturn)
inline void __attribute__ ((analyzer_noreturn)) juce_assert_noreturn() {}
#define JUCE_ANALYZER_NORETURN juce::juce_assert_noreturn();
#endif
#endif
#ifndef JUCE_ANALYZER_NORETURN
#define JUCE_ANALYZER_NORETURN
#endif
#if JUCE_CLANG
#if __has_cpp_attribute(clang::fallthrough)
#define JUCE_FALLTHROUGH [[clang::fallthrough]];
#else
#define JUCE_FALLTHROUGH
#endif
#elif JUCE_GCC
#if __GNUC__ >= 7
#define JUCE_FALLTHROUGH [[gnu::fallthrough]];
#else
#define JUCE_FALLTHROUGH
#endif
#else
#define JUCE_FALLTHROUGH
#endif
//==============================================================================
#if JUCE_MSVC && ! defined (DOXYGEN)
#define JUCE_BLOCK_WITH_FORCED_SEMICOLON(x) \
__pragma(warning(push)) \
__pragma(warning(disable:4127)) \
do { x } while (false) \
__pragma(warning(pop))
#else
#define JUCE_BLOCK_WITH_FORCED_SEMICOLON(x) do { x } while (false)
#endif
//==============================================================================
#if (JUCE_DEBUG && ! JUCE_DISABLE_ASSERTIONS) || DOXYGEN
#define DBG(textToWrite) JUCE_BLOCK_WITH_FORCED_SEMICOLON (juce::String tempDbgBuf; tempDbgBuf << textToWrite; juce::Logger::outputDebugString (tempDbgBuf);)
//==============================================================================
#define jassertfalse JUCE_BLOCK_WITH_FORCED_SEMICOLON (JUCE_LOG_CURRENT_ASSERTION; if (juce::juce_isRunningUnderDebugger()) JUCE_BREAK_IN_DEBUGGER; JUCE_ANALYZER_NORETURN)
//==============================================================================
#define jassert(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;)
#define jassertquiet(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;)
#else
//==============================================================================
// If debugging is disabled, these dummy debug and assertion macros are used..
#define DBG(textToWrite)
#define jassertfalse JUCE_BLOCK_WITH_FORCED_SEMICOLON (JUCE_LOG_CURRENT_ASSERTION;)
#if JUCE_LOG_ASSERTIONS
#define jassert(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;)
#define jassertquiet(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (! (expression)) jassertfalse;)
#else
#define jassert(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON ( ; )
#define jassertquiet(expression) JUCE_BLOCK_WITH_FORCED_SEMICOLON (if (false) (void) (expression);)
#endif
#endif
//==============================================================================
#ifndef DOXYGEN
#define JUCE_JOIN_MACRO_HELPER(a, b) a ## b
#define JUCE_STRINGIFY_MACRO_HELPER(a) #a
#endif
#define JUCE_JOIN_MACRO(item1, item2) JUCE_JOIN_MACRO_HELPER (item1, item2)
#define JUCE_STRINGIFY(item) JUCE_STRINGIFY_MACRO_HELPER (item)
//==============================================================================
#define JUCE_DECLARE_NON_COPYABLE(className) \
className (const className&) = delete;\
className& operator= (const className&) = delete;
#define JUCE_DECLARE_NON_MOVEABLE(className) \
className (className&&) = delete;\
className& operator= (className&&) = delete;
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className) \
JUCE_DECLARE_NON_COPYABLE(className) \
JUCE_LEAK_DETECTOR(className)
#define JUCE_PREVENT_HEAP_ALLOCATION \
private: \
static void* operator new (size_t) = delete; \
static void operator delete (void*) = delete;
//==============================================================================
#if JUCE_MSVC && ! defined (DOXYGEN)
#define JUCE_WARNING_HELPER(file, line, mess) message(file "(" JUCE_STRINGIFY (line) ") : Warning: " #mess)
#define JUCE_COMPILER_WARNING(message) __pragma(JUCE_WARNING_HELPER (__FILE__, __LINE__, message))
#else
#ifndef DOXYGEN
#define JUCE_WARNING_HELPER(mess) message(#mess)
#endif
#define JUCE_COMPILER_WARNING(message) _Pragma(JUCE_STRINGIFY (JUCE_WARNING_HELPER (message)))
#endif
//==============================================================================
#if JUCE_DEBUG || DOXYGEN
#define forcedinline inline
#else
#if JUCE_MSVC
#define forcedinline __forceinline
#else
#define forcedinline inline __attribute__ ((always_inline))
#endif
#endif
#if JUCE_MSVC || DOXYGEN
#define JUCE_ALIGN(bytes) __declspec (align (bytes))
#else
#define JUCE_ALIGN(bytes) __attribute__ ((aligned (bytes)))
#endif
//==============================================================================
#if JUCE_ANDROID && ! defined (DOXYGEN)
#define JUCE_MODAL_LOOPS_PERMITTED 0
#elif ! defined (JUCE_MODAL_LOOPS_PERMITTED)
#define JUCE_MODAL_LOOPS_PERMITTED 0
#endif
//==============================================================================
#if JUCE_GCC || JUCE_CLANG
#define JUCE_PACKED __attribute__ ((packed))
#elif ! defined (DOXYGEN)
#define JUCE_PACKED
#endif
//==============================================================================
#if JUCE_GCC || DOXYGEN
#define JUCE_NO_ASSOCIATIVE_MATH_OPTIMISATIONS __attribute__ ((__optimize__ ("no-associative-math")))
#else
#define JUCE_NO_ASSOCIATIVE_MATH_OPTIMISATIONS
#endif
} // namespace juce