w1146869587
2021-11-05 cbf39419a8299e7d119618e5e8e1b1eb35f72f45
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <efsw/Debug.hpp>
#include <iostream>
 
#ifdef EFSW_COMPILER_MSVC
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <crtdbg.h>
#endif
 
#include <cassert>
#include <cstdio>
#include <cstdarg>
 
namespace efsw {
 
#ifdef DEBUG
 
void efREPORT_ASSERT( const char * File, int Line, const char * Exp )
{
    #ifdef EFSW_COMPILER_MSVC
        _CrtDbgReport( _CRT_ASSERT, File, Line, "", Exp);
 
        DebugBreak();
    #else
        std::cout << "ASSERT: " << Exp << " file: " << File << " line: " << Line << std::endl;
 
        #if defined(EFSW_COMPILER_GCC) && defined(EFSW_32BIT) && !defined(EFSW_ARM)
            asm("int3");
        #else
            assert( false );
        #endif
    #endif
}
 
void efPRINT( const char * format, ... )
{
    char        buf[2048];
    va_list        args;
 
    va_start( args, format );
 
    #ifdef EFSW_COMPILER_MSVC
        _vsnprintf_s( buf, sizeof( buf ), sizeof( buf ) / sizeof( buf[0]), format, args );
    #else
        vsnprintf( buf, sizeof( buf ) / sizeof( buf[0]), format, args );
    #endif
 
    va_end( args );
 
    #ifdef EFSW_COMPILER_MSVC
        OutputDebugStringA( buf );
    #else
        std::cout << buf;
    #endif
}
 
void efPRINTC( unsigned int cond, const char * format, ...)
{
    if ( 0 == cond )
        return;
 
    char        buf[2048];
    va_list        args;
 
    va_start( args, format );
 
    #ifdef EFSW_COMPILER_MSVC
        _vsnprintf_s( buf, efARRAY_SIZE( buf ), efARRAY_SIZE( buf ), format, args );
    #else
        vsnprintf( buf, sizeof( buf ) / sizeof( buf[0]), format, args );
    #endif
 
    va_end( args );
 
    #ifdef EFSW_COMPILER_MSVC
        OutputDebugStringA( buf );
    #else
        std::cout << buf;
    #endif
}
 
#endif
 
}