-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathassert.h
More file actions
31 lines (23 loc) · 936 Bytes
/
assert.h
File metadata and controls
31 lines (23 loc) · 936 Bytes
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
// This file is part of the "edge" library, available at https://github.com/adigostin/edge
// Copyright (c) 2011-2020 Adi Gostin, distributed under Apache License v2.0.
#pragma once
extern volatile unsigned int assert_function_running;
#undef assert
#ifdef _MSC_VER
extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(void);
extern __declspec(noinline) void __stdcall assert_function (const char* expression, const char* file, unsigned line);
#define assert(_Expression) (void)( (!!(_Expression)) || (::IsDebuggerPresent() ? __debugbreak() : assert_function(#_Expression, __FILE__, __LINE__), 0) )
#else
#ifdef __cplusplus
extern "C" {
#endif
extern void __assert(const char *__filename, int __line);
#ifdef __cplusplus
}
#endif
#ifdef NDEBUG
#define assert(ignore) ((void)0)
#else
#define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__))
#endif
#endif