File: tut4.html

package info (click to toggle)
libcwd 1.0.4-1.1
  • links: PTS
  • area: non-free
  • in suites: jessie, jessie-kfreebsd
  • size: 8,136 kB
  • ctags: 10,313
  • sloc: cpp: 23,354; sh: 9,798; ansic: 1,172; makefile: 852; exp: 234; awk: 11
file content (99 lines) | stat: -rw-r--r-- 4,822 bytes parent folder | download | duplicates (5)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML LANG="en-us">
<HEAD>
<META name="Author" content="Carlo Wood">
<META http-equiv="content-type" content="text/html; charset=iso-8859-1">
<META http-equiv="content-script-type" content="text/javascript">
<TITLE>libcwd: The C++ Debugging Support Library - Tutorial</TITLE>
<SCRIPT SRC="../scripts/detect_browser.js"></SCRIPT>
<SCRIPT>need_style_tutorial=1</SCRIPT>
<SCRIPT SRC="../scripts/load_style_sheets.js"></SCRIPT>
</HEAD>
<BODY>

<TABLE class="header" height=64 width="100%" cellpadding=0 cellspacing=0 border=0>
  <TR>
    <TD width=237 valign=top>
      <IMG valign=top src="../images/libcwd_logo.png" alt="" align=left border=0>
    </TD>
    <TD width="100%" align=center>
      <DIV class="header-title">
      The C++ Debugging Support Library
      </DIV>
      <DIV class="header-copyright">
      By Carlo Wood, &copy;1999 - 2003.
      </DIV>
    </TD>
  </TR>
  <SCRIPT>if (is_mozilla4) document.write("<TR><TD colspan=2 height=19 valign=bottom><HR SIZE=2 NOSHADE></TD></TR>");</SCRIPT>
</TABLE>

<DIV class="body">

<H2>Tutorial 4: Management of <CODE>CWDEBUG</CODE></H2>

<P>In a production environment you most likely want to remove all debugging code from
the application because it makes the application slower, of course.&nbsp;
You can do this by compiling the final application <EM>without</EM> defining the macro <CODE>CWDEBUG</CODE>.&nbsp;
You also don't need to link with libcwd in that case.</P>

<P>In example, with debugging code you'd compile a program as</P>

<P class="shell-command">g++ -g -DCWDEBUG application.cc -lcwd -o application</P>

<P>and without debugging code you'd use</P>

<P class="shell-command">g++ -O3 application.cc -o application</P>

<P>Because the final application doesn't need libcwd, we can afford to use features of g++ and
third party libraries that developers are able to install but that would be impractical as demand for
the end-user of the application.&nbsp; The <EM>developer</EM> that uses libcwd will have to use
g++ as compiler and perhaps use a linux box for the development of the application, but gets a lot
of developing advantages in return.&nbsp; Afterwards it is relatively easy to port the bug-free
code to other platforms/compilers.</P>

<P>As a developer you need to know two things:</P>
<OL TYPE="1">
<LI>How to compile the application you are developing, while you're still developing it.</LI>
<LI>How to compile a final version of your application, without debugging support.</LI>
</OL>

<P>In the first case, all libraries and your application need to be compiled with <CODE>CWDEBUG</CODE> defined.&nbsp;
In the second case all libraries, except libcwd (because you won't link with it) and your application, need to be compiled
with <CODE>CWDEBUG</CODE> undefined.</P>

<P>Libraries that do not use libcwd (or otherwise depend on the macro
<CODE>CWDEBUG</CODE>) do not need to be recompiled of course.&nbsp;
If you are writing an end-application and do not have other libraries that depend on
libcwd (or otherwise depend on the macro <CODE>CWDEBUG</CODE>)
then it is as easy as defining <CODE>CWDEBUG</CODE> and linking
with libcwd, or not defining it and not linking with libcwd.&nbsp;
However, if you are using other libraries that depend on or use libcwd, then these need to
be recompiled too before linking with them.&nbsp;
If you are writing a library yourself then at least distribute a version without debug support, but consider
to also release a developers version with debug support turned on.&nbsp;
Realize however that the meaning of the macro <CODE>CWDEBUG</CODE> is: debugging the
application that is developed <EM>with</EM> a library, not debugging the library
itself! Testing a library is best done with seperate test applications.&nbsp;
If extra debugging code is needed to test the library itself then use a library
specific define like <CODE>DEBUG_YOURLIB</CODE>.</P>

<P>Finally, in order for others to be able to compile your application without having
libcwd installed, you need to include a custom "debug.h" and "sys.h" as is described
in chapter <A HREF="../reference-manual/preparation.html#preparation">Preparation</A> of
the <A HREF="../reference-manual/index.html">Reference Manual</A> and in <A HREF="tut2.html">tutorial 2</A>.</P>


</DIV>
<P class="line"><IMG width=870 height=23 src="../images/lines/snail.png"></P>
<DIV class="buttons">
<A HREF="tut3.html"><IMG width=64 height=32 src="../images/buttons/lr_prev.png" border="0"></A>
<A HREF="index.html"><IMG width=64 height=32 src="../images/buttons/lr_index.png" border="0"></A>
<A HREF="tut5.html"><IMG width=64 height=32 src="../images/buttons/lr_next.png" border="0"></A>
</DIV>

<ADDRESS>Copyright &copy; 2001, 2002 Carlo Wood.&nbsp; All rights reserved.</ADDRESS>

</BODY>
</HTML>