JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
fdebug.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------
2// Project : SDK Base
3// Version : 1.0
4//
5// Category : Helpers
6// Filename : base/source/fdebug.h
7// Created by : Steinberg, 1995
8// Description : There are 2 levels of debugging messages:
9// DEVELOPMENT During development
10// RELEASE Program is shipping.
11//
12//-----------------------------------------------------------------------------
13// LICENSE
14// (c) 2023, Steinberg Media Technologies GmbH, All Rights Reserved
15//-----------------------------------------------------------------------------
16// Redistribution and use in source and binary forms, with or without modification,
17// are permitted provided that the following conditions are met:
18//
19// * Redistributions of source code must retain the above copyright notice,
20// this list of conditions and the following disclaimer.
21// * Redistributions in binary form must reproduce the above copyright notice,
22// this list of conditions and the following disclaimer in the documentation
23// and/or other materials provided with the distribution.
24// * Neither the name of the Steinberg Media Technologies nor the names of its
25// contributors may be used to endorse or promote products derived from this
26// software without specific prior written permission.
27//
28// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
29// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
32// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
36// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
37// OF THE POSSIBILITY OF SUCH DAMAGE.
38//-----------------------------------------------------------------------------
39
40//-----------------------------------------------------------------------------
50//-----------------------------------------------------------------------------
51#pragma once
52
54#include <cstring>
55
56#if SMTG_OS_MACOS
57#include <new>
58#endif
59
62
63//-----------------------------------------------------------------------------
64// development / release
65//-----------------------------------------------------------------------------
66#if !defined (DEVELOPMENT) && !defined (RELEASE)
67 #ifdef _DEBUG
68 #define DEVELOPMENT 1
69 #elif defined (NDEBUG)
70 #define RELEASE 1
71 #else
72 #error DEVELOPMENT, RELEASE, _DEBUG, or NDEBUG must be defined!
73 #endif
74#endif
75
76//-----------------------------------------------------------------------------
77#if SMTG_OS_WINDOWS
78
82#if DEVELOPMENT && defined(_MSC_VER)
83#pragma warning(disable : 4291)
84#pragma warning(disable : 4985)
85#endif
86
87#endif // SMTG_OS_WINDOWS
88
89#if DEVELOPMENT
90//-----------------------------------------------------------------------------
96#define SMTG_ASSERT(f) \
97 if (!(f)) \
98 FDebugBreak ("%s(%d) : Assert failed: %s\n", __FILE__, __LINE__, #f);
99
100#define SMTG_ASSERT_MSG(f, msg) \
101 if (!(f)) \
102 FDebugBreak ("%s(%d) : Assert failed: [%s] [%s]\n", __FILE__, __LINE__, #f, msg);
103
105#define SMTG_WARNING(comment) FDebugPrint ("%s(%d) : %s\n", __FILE__, __LINE__, comment);
106
108#define SMTG_PRINTSYSERROR FPrintLastError (__FILE__, __LINE__);
109
112#define SMTG_DEBUGSTR(s) FDebugBreak (s);
113
117#define SMTG_VERIFY(f) SMTG_ASSERT (f)
118
122#define SMTG_VERIFY_IS(f, r) \
123 if ((f) != (r)) \
124 FDebugBreak ("%s(%d) : Assert failed: %s\n", __FILE__, __LINE__, #f);
125
129#define SMTG_VERIFY_NOT(f, r) \
130 if ((f) == (r)) \
131 FDebugBreak ("%s(%d) : Assert failed: %s\n", __FILE__, __LINE__, #f);
132
138#define SMTG_DBPRT0(a) FDebugPrint (a);
139#define SMTG_DBPRT1(a, b) FDebugPrint (a, b);
140#define SMTG_DBPRT2(a, b, c) FDebugPrint (a, b, c);
141#define SMTG_DBPRT3(a, b, c, d) FDebugPrint (a, b, c, d);
142#define SMTG_DBPRT4(a, b, c, d, e) FDebugPrint (a, b, c, d, e);
143#define SMTG_DBPRT5(a, b, c, d, e, f) FDebugPrint (a, b, c, d, e, f);
145
152void FDebugPrint (const char* format, ...);
153void FDebugBreak (const char* format, ...);
154void FPrintLastError (const char* file, int line);
156
162using AssertionHandler = bool (*) (const char* message);
163extern AssertionHandler gAssertionHandler;
164extern AssertionHandler gPreAssertionHook;
165using DebugPrintLogger = void (*) (const char* message);
166extern DebugPrintLogger gDebugPrintLogger;
168
172#if SMTG_OS_MACOS
173void* operator new (size_t, int, const char*, int);
174void* operator new[] (size_t, int, const char*, int);
175void operator delete (void* p, int, const char* file, int line);
176void operator delete[] (void* p, int, const char* file, int line);
177#ifndef NEW
178#define NEW new (1, __FILE__, __LINE__)
179#define NEWVEC new (1, __FILE__, __LINE__)
180#endif
181
182#define DEBUG_NEW DEBUG_NEW_LEAKS
183
184#elif SMTG_OS_WINDOWS && defined(_MSC_VER)
185#ifndef NEW
186void* operator new (size_t, int, const char*, int);
187#define NEW new (1, __FILE__, __LINE__)
188#define NEWVEC new (1, __FILE__, __LINE__)
189#endif
190
191#else
192#ifndef NEW
193#define NEW new
194#define NEWVEC new
195#endif
196#endif
197
198#else
200#define SMTG_ASSERT(f)
201#define SMTG_ASSERT_MSG(f, msg)
202#define SMTG_WARNING(s)
203#define SMTG_PRINTSYSERROR
204#define SMTG_DEBUGSTR(s)
205#define SMTG_VERIFY(f) f;
206#define SMTG_VERIFY_IS(f, r) f;
207#define SMTG_VERIFY_NOT(f, r) f;
208
209#define SMTG_DBPRT0(a)
210#define SMTG_DBPRT1(a, b)
211#define SMTG_DBPRT2(a, b, c)
212#define SMTG_DBPRT3(a, b, c, d)
213#define SMTG_DBPRT4(a, b, c, d, e)
214#define SMTG_DBPRT5(a, b, c, d, e, f)
215
216#ifndef NEW
217#define NEW new
218#define NEWVEC new
219
220#endif
221#endif
222
223// replace #if SMTG_CPPUNIT_TESTING
224bool isSmtgUnitTesting ();
225void setSmtgUnitTesting ();
226
227#if !SMTG_RENAME_ASSERT
228#if SMTG_OS_WINDOWS
229#undef ASSERT
230#endif
231
232#define ASSERT SMTG_ASSERT
233#define WARNING SMTG_WARNING
234#define DEBUGSTR SMTG_DEBUGSTR
235#define VERIFY SMTG_VERIFY
236#define VERIFY_IS SMTG_VERIFY_IS
237#define VERIFY_NOT SMTG_VERIFY_NOT
238#define PRINTSYSERROR SMTG_PRINTSYSERROR
239
240#define DBPRT0 SMTG_DBPRT0
241#define DBPRT1 SMTG_DBPRT1
242#define DBPRT2 SMTG_DBPRT2
243#define DBPRT3 SMTG_DBPRT3
244#define DBPRT4 SMTG_DBPRT4
245#define DBPRT5 SMTG_DBPRT5
246#endif
bool AmIBeingDebugged()
Returns true if a debugger is attached.
typedef int
typedef size_t