-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_output.h
More file actions
81 lines (72 loc) · 1.69 KB
/
debug_output.h
File metadata and controls
81 lines (72 loc) · 1.69 KB
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
#ifndef DEBUG_OUTPUT_H
#define DEBUG_OUTPUT_H
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
int debug_printf(const char* fmt, ...);
int debug_puts(const char* str);
int debug_fputs(const char* restrict str, FILE* restrict stream);
int debug_putc(int ch, FILE* stream);
int debug_fputc(int ch, FILE* stream);
#ifdef DO_DEBUG
int debug_printf(const char* fmt, ...)
{
va_list arg;
va_start(arg, fmt);
int result = vprintf(fmt, arg);
va_end(arg);
return result;
}
int debug_puts(const char* str)
{
return puts(str);
}
int debug_fputs(const char* restrict str, FILE* restrict stream)
{
return fputs(str, stream);
}
int debug_putc(int ch, FILE* stream)
{
return putc(ch, stream);
}
int debug_fputc(int ch, FILE* stream)
{
return fputc(ch, stream);
}
#define debug_assert(x) assert(x)
#define DEBUG_PRINTF debug_printf
#define DEBUG_PUTS debug_puts
#define DEBUG_FPUTS debug_fputs
#define DEBUG_PUTC debug_putc
#define DEBUG_FPUTC debug_fputc
#define DEBUG_ASSERT assert
#else // DO_DEBUG
int debug_printf(const char* fmt, ...)
{
return 0;
}
int debug_puts(const char* str)
{
return 0;
}
int debug_fputs(const char* restrict str, FILE* restrict stream)
{
return 0;
}
int debug_putc(int ch, FILE* stream)
{
return ch;
}
int debug_fputc(int ch, FILE* stream)
{
return ch;
}
#define debug_assert(x) do {(x);} while (0)
#define DEBUG_PRINTF(...) do {} while (0)
#define DEBUG_PUTS(...) do {} while (0)
#define DEBUG_FPUTS(...) do {} while (0)
#define DEBUG_PUTC(...) do {} while (0)
#define DEBUG_FPUTC(...) do {} while (0)
#define DEBUG_ASSERT(...) do {} while (0)
#endif // DO_DEBUG
#endif // DEBUG_OUTPUT_H