Home
Getting started
Components overview
Topics
Components
Classes
Tutorials and Examples
Code snippets
Support
AppAssert.h
1
//##################################################################################################
2
//
3
// Ceetron Desktop Components
4
// Component: Core
5
//
6
// --------------------------------------------------------------------------------------------
7
// Copyright (C) 2019, Ceetron AS
8
// This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9
// not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10
// without the prior written permission of Ceetron AS.
11
//##################################################################################################
12
13
#pragma once
14
15
#include "CeeCore/Base.h"
16
17
namespace
cee
{
18
19
20
//==================================================================================================
21
//
22
// Static helper class for handling assert failures in CDC
23
//
24
//==================================================================================================
25
class
CEE_CORE_EXPORT
AssertHelper
26
{
27
public
:
28
enum
PostFailAction
29
{
30
CONTINUE,
// Continue execution
31
DEBUGBREAK
// Execution should be stopped and debugger should be triggered (currently windows only)
32
};
33
34
public
:
35
static
PostFailAction handleFailedAssert(
const
char
* fileName,
int
lineNumber,
const
char
* expr,
const
char
* msg);
36
};
37
38
}
// namespace cee
39
40
41
42
// Default behavior for assert macros
43
// In debug builds, all asserts are in action, both normal asserts and tight asserts
44
// In release builds, tight asserts are disabled by default while normal asserts are still in action
45
#ifndef CEE_ENABLE_APP_ASSERTS
46
#define CEE_ENABLE_APP_ASSERTS 1
47
#endif
48
49
#ifndef CEE_ENABLE_TIGHT_APP_ASSERTS
50
#ifdef _DEBUG
51
#define CEE_ENABLE_TIGHT_APP_ASSERTS 1
52
#else
53
#define CEE_ENABLE_TIGHT_APP_ASSERTS 0
54
#endif
55
#endif
56
57
58
// Define to trigger debug trap for use with assert macros on Windows
59
#ifdef WIN32
60
#define CEE_APP_ASSERT_DEBUGTRAP() __debugbreak()
61
#else
62
#define CEE_APP_ASSERT_DEBUGTRAP() ((void)0)
63
#endif
64
65
66
67
// Define our assert macros
68
#if CEE_ENABLE_APP_ASSERTS == 1
69
#define CEE_APP_ASSERT(expr) (void)( (!!(expr)) || (cee::AssertHelper::CONTINUE == cee::AssertHelper::handleFailedAssert(__FILE__, __LINE__, #expr, NULL)) || (CEE_APP_ASSERT_DEBUGTRAP(), 0) )
70
#define CEE_APP_ASSERT_MSG(expr, msg) (void)( (!!(expr)) || (cee::AssertHelper::CONTINUE == cee::AssertHelper::handleFailedAssert(__FILE__, __LINE__, #expr, (msg))) || (CEE_APP_ASSERT_DEBUGTRAP(), 0) )
71
#define CEE_APP_FAIL_MSG(msg) (void)( (cee::AssertHelper::CONTINUE == cee::AssertHelper::handleFailedAssert(__FILE__, __LINE__, NULL, (msg))) || (CEE_APP_ASSERT_DEBUGTRAP(), 0) )
72
#else
73
#define CEE_APP_ASSERT(expr) ((void)0)
74
#define CEE_APP_ASSERT_MSG(expr, msg) ((void)0)
75
#define CEE_APP_FAIL_MSG(msg) ((void)0)
76
#endif
77
78
#if CEE_ENABLE_TIGHT_APP_ASSERTS == 1 && CEE_ENABLE_APP_ASSERTS == 1
79
#define CEE_APP_TIGHT_ASSERT(expr) CEE_APP_ASSERT(expr)
80
#else
81
#define CEE_APP_TIGHT_ASSERT(expr) ((void)0)
82
#endif
83
84
85
cee
Namespace cee contains all functionality and structures under the Core component. ...
Definition:
AppComponent.cpp:26
cee::AssertHelper
Definition:
AppAssert.h:25
CeeCore
AppAssert.h
Updated: Fri Dec 17 2021 - Copyright © 2021 Ceetron AS