Main Page
Reference Manual
Namespace List
Compound List
Namespace Members
Compound Members
File Members
libcwd
debug.h
Go to the documentation of this file.
1
// $Header$
2
//
3
// Copyright (C) 2000 - 2004, by
4
//
5
// Carlo Wood, Run on IRC <carlo@alinoe.com>
6
// RSA-1024 0x624ACAD5 1997-01-26 Sign & Encrypt
7
// Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF 61
8
//
9
// This file may be distributed under the terms of the Q Public License
10
// version 1.0 as appearing in the file LICENSE.QPL included in the
11
// packaging of this file.
12
//
13
23
#ifndef CWDEBUG
24
25
// If you run into this error then you included <libcwd/debug.h> (or any other libcwd header file)
26
// while the macro CWDEBUG was not defined. Doing so would cause the compilation of your
27
// application to fail on machines that do not have libcwd installed. Instead you should use:
28
// #include "debug.h"
29
// and add a file debug.h to your applications distribution. Please see the the example-project
30
// that comes with the source code of libcwd (or is included in the documentation that comes with
31
// the rpm (ie: /usr/doc/libcwd-1.0/example-project) for a description of the content of "debug.h".
32
// Note1: CWDEBUG should be defined on the compiler commandline, for example: g++ -DCWDEBUG ...
33
#error "You are including <libcwd/debug.h> while CWDEBUG is not defined. See the comments in this header file for more information."
34
35
#else // CWDEBUG (normal usage of this file):
36
37
#ifndef LIBCWD_SYS_H
38
#error "You need to #include "sys.h" at the top of every source file (which in turn should #include <libcwd/sys.h>)."
39
#endif
40
41
#if defined(LIBCWD_DEFAULT_DEBUGCHANNELS) && defined(DEBUGCHANNELS)
42
// If you run into this error then you included <libcwd/debug.h> (or any other libcwd header file)
43
// without defining DEBUGCHANNELS, and later (the moment of this error) you included it with
44
// DEBUGCHANNELS defined.
45
//
46
// The most likely reason for this is that you include <libcwd/debug.h> in one of your headers
47
// instead of using #include "debug.h", and then included that header file before including
48
// "debug.h" in the .cpp file.
49
// End-applications should #include "debug.h" everywhere. See the the example-project that comes
50
// with the source code of libcwd (or is included in the documentation that comes with the rpm
51
// (ie: /usr/doc/libcwd-1.0/example-project) for a description of the content of "debug.h".
52
// More information for end-application users can be found on
53
// http://libcwd.sourceforge.net/reference-manual/preparation.html
54
//
55
// Third-party libraries should never include <libcwd/debug.h> but also not "debug.h". They
56
// should include <libcwd/libraries_debug.h> (and not use Dout et al in their headers). If you
57
// are using a library that did include <libcwd/debug.h> then please report this bug the author
58
// of that library. You can workaround it for now by including "debug.h" before including the
59
// header of that library.
60
// More information for library authors that use libcwd can be found on
61
// http://libcwd.sourceforge.net/reference-manual/group__chapter__custom__debug__h.html
62
#error "DEBUGCHANNELS is defined while previously it was not defined. See the comments in this header file for more information."
63
#endif
64
65
#endif // CWDEBUG
66
67
#ifndef LIBCWD_DEBUG_H
68
#define LIBCWD_DEBUG_H
69
70
#ifdef CWDEBUG
71
72
// The following header is also needed for end-applications, despite its name.
73
#include <
libcwd/libraries_debug.h
>
74
75
#ifndef LIBCWD_DOXYGEN
76
77
// The real code
78
#ifdef DEBUGCHANNELS
79
#define LIBCWD_DEBUGCHANNELS DEBUGCHANNELS
80
#else
81
#define LIBCWD_DEBUGCHANNELS libcwd::channels
82
#define LIBCWD_DEFAULT_DEBUGCHANNELS
83
#endif
84
85
#else // LIBCWD_DOXYGEN
86
87
// This is only here for the documentation. The user will define DEBUGCHANNELS, not LIBCWD_DEBUGCHANNELS.
94
#define DEBUGCHANNELS
95
#endif // LIBCWD_DOXYGEN
96
97
// For use in applications
124
#define Debug(STATEMENTS...) \
125
LibcwDebug(LIBCWD_DEBUGCHANNELS, STATEMENTS)
126
154
#define Dout(cntrl, data) \
155
LibcwDout(LIBCWD_DEBUGCHANNELS, ::libcwd::libcw_do, cntrl, data)
156
164
#define DoutFatal(cntrl, data) \
165
LibcwDoutFatal(LIBCWD_DEBUGCHANNELS, ::libcwd::libcw_do, cntrl, data)
166
190
#define ForAllDebugChannels(STATEMENT...) \
191
LibcwdForAllDebugChannels(LIBCWD_DEBUGCHANNELS, STATEMENT)
192
209
#define ForAllDebugObjects(STATEMENT...) \
210
LibcwdForAllDebugObjects(LIBCWD_DEBUGCHANNELS, STATEMENT)
211
212
// Finally, in order for Dout() to be usable, we need this.
213
#ifndef LIBCW_IOSTREAM
214
#define LIBCW_IOSTREAM
215
#include <iostream>
216
#endif
217
218
#endif // CWDEBUG
219
#endif // LIBCWD_DEBUG_H
libraries_debug.h
This is the header file that third-party library headers should include.
Copyright © 2001 - 2004 Carlo Wood. All rights reserved.