Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
IssueReporting.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
10using TraceFunction = void (*)(const char *inFMT, ...);
12
13// Always turn on asserts in Debug mode
14#if defined(JPH_DEBUG) && !defined(JPH_ENABLE_ASSERTS)
15 #define JPH_ENABLE_ASSERTS
16#endif
17
18#ifdef JPH_ENABLE_ASSERTS
20 using AssertFailedFunction = bool(*)(const char *inExpression, const char *inMessage, const char *inFile, uint inLine);
21 JPH_EXPORT extern AssertFailedFunction AssertFailed;
22
23 // Helper functions to pass message on to failed function
24 struct AssertLastParam { };
25 inline bool AssertFailedParamHelper(const char *inExpression, const char *inFile, uint inLine, AssertLastParam) { return AssertFailed(inExpression, nullptr, inFile, inLine); }
26 inline bool AssertFailedParamHelper(const char *inExpression, const char *inFile, uint inLine, const char *inMessage, AssertLastParam) { return AssertFailed(inExpression, inMessage, inFile, inLine); }
27
29 #define JPH_ASSERT(inExpression, ...) do { if (!(inExpression) && AssertFailedParamHelper(#inExpression, __FILE__, JPH::uint(__LINE__), ##__VA_ARGS__, JPH::AssertLastParam())) JPH_BREAKPOINT; } while (false)
30
31 #define JPH_IF_ENABLE_ASSERTS(...) __VA_ARGS__
32#else
33 #define JPH_ASSERT(...) ((void)0)
34
35 #define JPH_IF_ENABLE_ASSERTS(...)
36#endif // JPH_ENABLE_ASSERTS
37
#define JPH_EXPORT
Definition Core.h:236
unsigned int uint
Definition Core.h:453
#define JPH_NAMESPACE_END
Definition Core.h:379
#define JPH_NAMESPACE_BEGIN
Definition Core.h:373
void(*)(const char *inFMT,...) TraceFunction
Trace function, needs to be overridden by application. This should output a line of text to the log /...
Definition IssueReporting.h:10
JPH_EXPORT TraceFunction Trace
Definition IssueReporting.cpp:18