VR-Engage
2.2
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,
const
char
* expression,
const
char
* description,
int
line,
const
char
* file,
39
const
char
* function,
bool
* handled);
40
41
42
//! \brief Primary assertion macro for runtime validation
43
//!
44
//! This macro takes an expression that evaluates to true/false and a text description.
45
//! If the expression evaluates to false, this will show an assertion dialog (on Windows)
46
//! or output a console message (on Linux) with options to Abort, Retry, or Ignore.
47
//! - Abort: breaks into the debugger
48
//! - Retry: continues running, but the assertion will fire again if the expression evaluates to false again
49
//! - Ignore: suppresses this assertion and continues running
50
//!
51
//! \param exp The expression to evaluate
52
//! \param description Descriptive message about the assertion condition
53
#define DtASSERT(exp, description) \
54
{ \
55
static bool ignoreAlways = false; \
56
if (!ignoreAlways) \
57
{ \
58
if (makVre::customAssert(bool(exp), #exp, description, __LINE__, __FILE__, __FUNCTION__, &ignoreAlways)) \
59
{ \
60
ASSERT_BREAK; \
61
} \
62
} \
63
}
64
65
#if !defined(NIGHTLYBUILD)
66
//! \brief Development-only assertion macro
67
//!
68
//! Similar to DtASSERT but only active in development builds.
69
//! This assertion is disabled in nightly builds to avoid disrupting automated testing.
70
//!
71
//! \param exp The expression to evaluate
72
//! \param description Descriptive message about the assertion condition
73
#define DtDEV_ASSERT(exp, description) \
74
{ \
75
static bool ignoreAlways = false; \
76
if (!ignoreAlways) \
77
{ \
78
if (makVre::customAssert(bool(exp), #exp, description, __LINE__, __FILE__, __FUNCTION__, &ignoreAlways)) \
79
{ \
80
ASSERT_BREAK; \
81
} \
82
} \
83
}
84
#else
85
86
//! \brief No-op version of DtDEV_ASSERT for nightly builds
87
#define DtDEV_ASSERT(exp, description)
88
89
#endif
90
91
}
// 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
Include export definitions for this library.
Definition
glsVreMessageUtil.h:49
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-01-13 from SVN revision 282860 - Copyright © 2005-2026 MAK Technologies. All Rights Reserved.