VR-Engage
2.3
Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
1
/*********************************************************************************
2
** Copyright (c) 2025 MAK Technologies
3
** All rights reserved.
4
*********************************************************************************/
5
6
#pragma once
7
8
//! \file assert.h
9
//! \brief Provides assertion macros and functions for error detection and handling
10
11
#include "
vreUtil/export.h
"
12
13
#ifdef _WIN32
14
#include "intrin.h"
15
#endif
16
17
18
namespace
makVre
19
{
20
#ifdef _WIN32
21
//! \brief Platform-specific debugger break instruction for Windows
22
#define ASSERT_BREAK __debugbreak();
23
#else
24
//! \brief Platform-specific debugger break instruction for non-Windows platforms
25
#define ASSERT_BREAK asm("int $3");
26
#endif
27
28
//! \brief Custom assertion function that evaluates conditions and handles failures
29
//!
30
//! \param condition The boolean condition to evaluate
31
//! \param expression The string representation of the expression being evaluated
32
//! \param description The error description message
33
//! \param line The line number where the assertion occurred
34
//! \param file The source file where the assertion occurred
35
//! \param function The function name where the assertion occurred
36
//! \param handled Pointer to boolean that will be set to true if the assertion was handled
37
//! \return true if the debugger should break, false otherwise
38
UTIL_DLL
bool
customAssert
(
bool
condition,
39
const
char
* expression,
40
const
char
* description,
41
int
line,
42
const
char
* file,
43
const
char
* function,
44
bool
* handled);
45
46
47
//! \brief Primary assertion macro for runtime validation
48
//!
49
//! This macro takes an expression that evaluates to true/false and a text description.
50
//! If the expression evaluates to false, this will show an assertion dialog (on Windows)
51
//! or output a console message (on Linux) with options to Abort, Retry, or Ignore.
52
//! - Abort: breaks into the debugger
53
//! - Retry: continues running, but the assertion will fire again if the expression evaluates to false again
54
//! - Ignore: suppresses this assertion and continues running
55
//!
56
//! \param exp The expression to evaluate
57
//! \param description Descriptive message about the assertion condition
58
#define DtASSERT(exp, description) \
59
{ \
60
static bool ignoreAlways = false; \
61
if (!ignoreAlways) \
62
{ \
63
if (makVre::customAssert(bool(exp), #exp, description, __LINE__, __FILE__, __FUNCTION__, &ignoreAlways)) \
64
{ \
65
ASSERT_BREAK; \
66
} \
67
} \
68
}
69
70
#if !defined(NIGHTLYBUILD)
71
//! \brief Development-only assertion macro
72
//!
73
//! Similar to DtASSERT but only active in development builds.
74
//! This assertion is disabled in nightly builds to avoid disrupting automated testing.
75
//!
76
//! \param exp The expression to evaluate
77
//! \param description Descriptive message about the assertion condition
78
#define DtDEV_ASSERT(exp, description) \
79
{ \
80
static bool ignoreAlways = false; \
81
if (!ignoreAlways) \
82
{ \
83
if (makVre::customAssert(bool(exp), #exp, description, __LINE__, __FILE__, __FUNCTION__, &ignoreAlways)) \
84
{ \
85
ASSERT_BREAK; \
86
} \
87
} \
88
}
89
#else
90
91
//! \brief No-op version of DtDEV_ASSERT for nightly builds
92
#define DtDEV_ASSERT(exp, description)
93
94
#endif
95
96
}
// namespace makVre
export.h
Defines export macros for the VREngage Utility library.
UTIL_DLL
#define UTIL_DLL
Export/import macro for non-Windows platforms.
Definition
export.h:39
makVre
!
Definition
glsVreMessageUtil.h:50
makVre::customAssert
UTIL_DLL bool customAssert(bool condition, const char *expression, const char *description, int line, const char *file, const char *function, bool *handled)
Custom assertion function that evaluates conditions and handles failures.
Generated on 2026-10-22 from SVN revision 296863 - Copyright © 2005-2026 MAK Technologies. All Rights Reserved.