f25e1613ad52c7d5bdc78251ddd51f7ebd0d6c30
[reactos.git] / reactos / lib / crt / include / internal / debug.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: include/msvcrt/msvcrtdbg.h
5 * PURPOSE: Useful debugging macros
6 * PROGRAMMER:
7 * UPDATE HISTORY:
8 *
9 */
10
11 /*
12 * NOTE: Define NDEBUG before including this header to disable debugging
13 * macros
14 */
15
16 #ifndef __MSVCRT_DEBUG
17 #define __MSVCRT_DEBUG
18
19 #include <roscfg.h>
20 #include <windows.h>
21
22
23 #define MK_STR(s) #s
24
25 #ifdef _UNICODE
26 #define sT "S"
27 #else
28 #define sT "s"
29 #endif
30
31 unsigned long DbgPrint(char *Format,...);
32
33 #define TRACE(...)
34
35
36 #ifdef DBG
37 #ifdef __GNUC__
38 #define DPRINT1(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
39 #else
40 #define DPRINT1 DbgPrint
41 #endif
42 #define CHECKPOINT1 do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0);
43 #else
44 #ifdef __GNUC__
45 #define DPRINT1(args...)
46 #else
47 #define DPRINT DbgPrint
48 #endif
49 #define CHECKPOINT1
50 #endif
51
52 #if !defined(NDEBUG) && defined(DBG)
53 #define DPRINT(args...) do { DbgPrint("(MSVCRT:%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
54 #define CHECKPOINT do { DbgPrint("MSVCRT:%s:%d\n",__FILE__,__LINE__); } while(0);
55 #else
56 #ifdef __GNUC__
57 #define DPRINT(args...)
58 #else
59 #define DPRINT DbgPrint
60 #endif
61 #define CHECKPOINT
62 #endif /* NDEBUG */
63
64
65 #if 0
66
67 #define TRACE_RETURN(format_str, ret_type) \
68 ret_type __return_value__; \
69 static char* __return_format_str__ = "%s ret: "format_str"\n"
70
71 #define FUNCTION(func) \
72 static char* __func_name__ = #func
73
74 #define TRACE(a,b...) DPRINT1(a"\n", b)
75
76 #define RETURN(a) \
77 do{ __return_value__ = (a); DPRINT1(__return_format_str__ ,__func_name__,__return_value__); return __return_value__ ; }while(0)
78
79 #endif
80
81
82 /* ULONG CDECL DbgPrint(PCH Format, ...); */
83 ULONG DbgPrint(PCH Format,...);
84 /* unsigned long DbgPrint(const char* Format, ...); */
85
86
87
88 /* #define TRACE 0 ? (void)0 : Trace */
89
90 /* void Trace(TCHAR* lpszFormat, ...); */
91
92
93
94 #endif /* __MSVCRT_DEBUG */