-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMSF_Assert.cpp
More file actions
42 lines (35 loc) · 1.43 KB
/
MSF_Assert.cpp
File metadata and controls
42 lines (35 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "MSF_Assert.h"
#if MSF_ASSERTS_ENABLED
#include <stdio.h>
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
void (*MSF_LogAssertExternal)(const char* aFile, int aLine, char const* aCondition, MSF_StringFormat const& aStringFormat);
bool (*MSF_DoAssert)();
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
volatile bool theIsAsserting;
bool MSF_IsAsserting()
{
return theIsAsserting;
}
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
void MSF_LogAssertInternal(const char* aFile, int aLine, char const* aCondition, MSF_StringFormat const& aStringFormat)
{
// Don't allow asserts while asserting
if (theIsAsserting)
return;
theIsAsserting = true;
if (MSF_LogAssertExternal != nullptr)
{
MSF_LogAssertExternal(aFile, aLine, aCondition, aStringFormat);
}
else
{
char temporary[4096];
MSF_FormatString(aStringFormat, temporary, sizeof(temporary));
printf("%s(%d): %s failed: %s", aFile, aLine, aCondition, temporary);
}
theIsAsserting = false;
}
#endif