aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/efsw/Debug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdParty/efsw/Debug.cpp')
-rwxr-xr-xsrc/3rdParty/efsw/Debug.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/3rdParty/efsw/Debug.cpp b/src/3rdParty/efsw/Debug.cpp
new file mode 100755
index 0000000..18cfd31
--- /dev/null
+++ b/src/3rdParty/efsw/Debug.cpp
@@ -0,0 +1,81 @@
1#include <efsw/Debug.hpp>
2#include <iostream>
3
4#ifdef EFSW_COMPILER_MSVC
5#define WIN32_LEAN_AND_MEAN
6#include <crtdbg.h>
7#include <windows.h>
8#endif
9
10#include <cassert>
11#include <cstdarg>
12#include <cstdio>
13
14namespace efsw {
15
16#ifdef DEBUG
17
18void efREPORT_ASSERT( const char* File, int Line, const char* Exp ) {
19#ifdef EFSW_COMPILER_MSVC
20 _CrtDbgReport( _CRT_ASSERT, File, Line, "", Exp );
21
22 DebugBreak();
23#else
24 std::cout << "ASSERT: " << Exp << " file: " << File << " line: " << Line << std::endl;
25
26#if defined( EFSW_COMPILER_GCC ) && defined( EFSW_32BIT ) && !defined( EFSW_ARM )
27 asm( "int3" );
28#else
29 assert( false );
30#endif
31#endif
32}
33
34void efPRINT( const char* format, ... ) {
35 char buf[2048];
36 va_list args;
37
38 va_start( args, format );
39
40#ifdef EFSW_COMPILER_MSVC
41 _vsnprintf_s( buf, sizeof( buf ), sizeof( buf ) / sizeof( buf[0] ), format, args );
42#else
43 vsnprintf( buf, sizeof( buf ) / sizeof( buf[0] ), format, args );
44#endif
45
46 va_end( args );
47
48#ifdef EFSW_COMPILER_MSVC
49 OutputDebugStringA( buf );
50#else
51 std::cout << buf;
52#endif
53}
54
55void efPRINTC( unsigned int cond, const char* format, ... ) {
56 if ( 0 == cond )
57 return;
58
59 char buf[2048];
60 va_list args;
61
62 va_start( args, format );
63
64#ifdef EFSW_COMPILER_MSVC
65 _vsnprintf_s( buf, efARRAY_SIZE( buf ), efARRAY_SIZE( buf ), format, args );
66#else
67 vsnprintf( buf, sizeof( buf ) / sizeof( buf[0] ), format, args );
68#endif
69
70 va_end( args );
71
72#ifdef EFSW_COMPILER_MSVC
73 OutputDebugStringA( buf );
74#else
75 std::cout << buf;
76#endif
77}
78
79#endif
80
81} // namespace efsw