From: Carlo W. <li...@us...> - 2002-02-18 00:44:17
|
CVSROOT : /cvsroot/libcw Module : src Commit time: 2002-01-18 00:44:16 UTC Modified files: libcwd/documentation/styles/main.css libcwd/documentation/tutorial/channel.cc libcwd/documentation/tutorial/faq.m4 libcwd/documentation/tutorial/log_file.cc libcwd/documentation/tutorial/tut1.m4 libcwd/documentation/tutorial/tut2.m4 libcwd/documentation/tutorial/tut3.m4 libcwd/documentation/tutorial/tut4.m4 libcwd/documentation/tutorial/tut5.in libcwd/documentation/tutorial/tut6.m4 Log message: Misc tutorial fixes after rereading it. ---------------------- diff included ---------------------- Index: src/libcwd/documentation/styles/main.css diff -u src/libcwd/documentation/styles/main.css:1.4 src/libcwd/documentation/styles/main.css:1.5 --- src/libcwd/documentation/styles/main.css:1.4 Sun Feb 17 07:00:49 2002 +++ src/libcwd/documentation/styles/main.css Sun Feb 17 16:44:05 2002 @@ -212,7 +212,7 @@ } .shell-command { - font-family : ludica; + font-family : fixed, monospace; font-size : NORMAL_SIZE; } Index: src/libcwd/documentation/tutorial/channel.cc diff -u src/libcwd/documentation/tutorial/channel.cc:1.4 src/libcwd/documentation/tutorial/channel.cc:1.5 --- src/libcwd/documentation/tutorial/channel.cc:1.4 Sun Feb 17 07:30:15 2002 +++ src/libcwd/documentation/tutorial/channel.cc Sun Feb 17 16:44:06 2002 @@ -13,12 +13,13 @@ #define DEBUGCHANNELS ::example // Where we'll put our namespace dc // "debug.h": #include <libcw/debug.h> +//------------------------------------------------------------------------------- + namespace example { // namespace dc cannot be put in :: namespace dc { libcw::debug::channel_ct ghost("GHOST"); // Create our own Debug Channel } } -//------------------------------------------------------------------------------- int main(void) { @@ -26,7 +27,7 @@ Debug( libcw_do.on() ); // the debug Channel and Object on! for (int i = 0; i < 4; ++i) - Dout( dc::ghost, "i = " << i ); // We can write more than just + Dout(dc::ghost, "i = " << i); // We can write more than just // "Hello World" to the ostream :) return 0; } Index: src/libcwd/documentation/tutorial/faq.m4 diff -u src/libcwd/documentation/tutorial/faq.m4:1.7 src/libcwd/documentation/tutorial/faq.m4:1.8 --- src/libcwd/documentation/tutorial/faq.m4:1.7 Sun Feb 17 08:37:33 2002 +++ src/libcwd/documentation/tutorial/faq.m4 Sun Feb 17 16:44:06 2002 @@ -24,11 +24,10 @@ what could possibly be wrong with your code. Once the application works, you don't have to define _GNU_SOURCE because you won't be including the debug code anymore, nor link with -libcwd. If you need to write 100% ANSI code and you are not sure -whether or not new code that you added is an extension or not, you -should try to compile it with CWDEBUG undefined <EM>and</EM> using -ansi as -command line option to g++; without -ansi g++-3.0 and higher defines -_GNU_SOURCE itself by default.</P> +libcwd. +Note that GNU g++ 3.x already defines this macro currently itself as a hack +to get the libstdc++ headers work properly, hence the test with <CODE>#ifndef</CODE> +is always needed (see <A HREF="http://gcc.gnu.org/ml/gcc/2002-02/msg00996.html">http://gcc.gnu.org/ml/gcc/2002-02/msg00996.html</A>).</P> <A name="sysd.h"></A> <H3>2. Why do I have to include "libcw/sysd.h" as first header file?</H3> @@ -82,7 +81,7 @@ <H3>5. What is defined <EM>exactly</EM> in <SPAN class="H3code">libcw/debug.h</SPAN>?</H3> <P>Everything. -Go and read the <A HREF="../html/reference.html>Reference Manual</A> to get <EM>all</EM> gory details if you dare.</P> +Go and read the <A HREF="../html/reference.html">Reference Manual</A> to get <EM>all</EM> gory details if you dare.</P> <A name="macros"></A> <H3>6. Why are you using macros for <SPAN class="H3code">Debug</SPAN> and <SPAN class="H3code">Dout</SPAN>?</H3> Index: src/libcwd/documentation/tutorial/log_file.cc diff -u src/libcwd/documentation/tutorial/log_file.cc:1.5 src/libcwd/documentation/tutorial/log_file.cc:1.6 --- src/libcwd/documentation/tutorial/log_file.cc:1.5 Sun Feb 17 08:37:33 2002 +++ src/libcwd/documentation/tutorial/log_file.cc Sun Feb 17 16:44:06 2002 @@ -9,6 +9,7 @@ // "debug.h" #include <libcw/debug.h> //------------------------------------------------------------------------------- + #include <fstream> int main(void) @@ -24,7 +25,7 @@ // Set the ostream related with libcw_do to `file': Debug( libcw_do.set_ostream(&file) ); - Dout( dc::notice, "Hippopotamus are heavy" ); + Dout(dc::notice, "Hippopotamus are heavy"); return 0; } Index: src/libcwd/documentation/tutorial/tut1.m4 diff -u src/libcwd/documentation/tutorial/tut1.m4:1.8 src/libcwd/documentation/tutorial/tut1.m4:1.9 --- src/libcwd/documentation/tutorial/tut1.m4:1.8 Sun Feb 17 08:37:33 2002 +++ src/libcwd/documentation/tutorial/tut1.m4 Sun Feb 17 16:44:06 2002 @@ -26,7 +26,7 @@ Debug( dc::notice.on() ); // Turn on the NOTICE Debug Channel. Debug( libcw_do.on() ); // Turn on the default Debug Object. - Dout( dc::notice, "Hello World" ); + Dout(dc::notice, "Hello World"); return 0; } @@ -44,10 +44,7 @@ Note that you only really have to define it when you compiled libcwd with threading support. If you do not define this macro and libcwd needs it, then you will get -a compile error in <libcw/sysd.h> telling you so. -GNU gcc 3.0 (and higher) already defines this macro by itself, so there is -no need to include it if you intend to only compile your application with -this version.</P> +a compile error in <libcw/sysd.h> telling you so.</P> <DIV class="faq-frame"><H4>FAQ</H4><UL class="faq"> <LI><A HREF="faq.html#GNU_SOURCE">Won't this define make my code non-portable?</A></LI> @@ -81,8 +78,8 @@ <A NAME="turn_on_channel"></A> <H3></CODE>Debug( dc::notice.on() );</CODE></H3> -<P>This turns on the <I><U>D</U>ebug <U>C</U>hannel</I> <CODE> <U>dc</U>::notice</CODE>. -Without this line, the code <CODE>Dout( dc::notice, "Hello World" )</CODE> would output +<P>This turns on the <I><U>D</U>ebug <U>C</U>hannel</I> <CODE><U>dc</U>::notice</CODE>. +Without this line, the code <CODE>Dout(dc::notice, "Hello World")</CODE> would output nothing: all <I>Debug Channels</I> are <EM>off</EM> by default, at start up.</P> <DIV class="faq-frame"><H4>FAQ</H4><UL class="faq"> @@ -95,7 +92,7 @@ <H3><CODE>Debug( libcw_do.on() );</CODE></H3> <P>This turns on the <I><U>D</U>ebug <U>O</U>bject</I> <CODE>libcw_<U>do</U></CODE>. -Without this line, the code <CODE>Dout( dc::notice, "Hello World" )</CODE> would output +Without this line, the code <CODE>Dout(dc::notice, "Hello World")</CODE> would output nothing: all <I>Debug Objects</I> are <EM>off</EM> by default, at start up.</P> <P>A <I>Debug Object</I> is related to exactly one <CODE>ostream</CODE>. @@ -114,7 +111,7 @@ <LI><A HREF="faq.html#Object">Why do you call it a Debug <EM>Object</EM>? What <EM>is</EM> a Debug Object?</A></LI> </UL></DIV> -<H3><CODE>Dout( dc::notice, "Hello World" );</CODE></H3> +<H3><CODE>Dout(dc::notice, "Hello World");</CODE></H3> <P>This outputs "Hello World" to the <CODE>ostream</CODE> currently related to <CODE>libcw_do</CODE> provided that the <I>Debug Channel</I> Index: src/libcwd/documentation/tutorial/tut2.m4 diff -u src/libcwd/documentation/tutorial/tut2.m4:1.6 src/libcwd/documentation/tutorial/tut2.m4:1.7 --- src/libcwd/documentation/tutorial/tut2.m4:1.6 Sun Feb 17 08:37:33 2002 +++ src/libcwd/documentation/tutorial/tut2.m4 Sun Feb 17 16:44:06 2002 @@ -9,8 +9,6 @@ In the example below we create a debug channel <CODE>dc::ghost</CODE> that will use the string "<SPAN class="output">GHOST</SPAN>" as label.</P> -<P class="download">[<A HREF="channel.cc">download</A>]</P> - <P>Create a file <CODE>"sys.h"</CODE> that is part of your application and put in it:</P> <PRE> #ifdef HAVE_CONFIG_H // This is just an example of what you could do @@ -75,6 +73,7 @@ #endif // DEBUG_H </PRE> <P>Finally write the program:</P> +<P class="download">[<A HREF="channel.cc">download</A>]</P> <PRE> #include "sys.h" #include "debug.h" @@ -92,8 +91,8 @@ Debug( libcw_do.on() ); // the debug Channel and Object on! for (int i = 0; i < 4; ++i) - Dout( <SPAN class="highlight">dc::ghost</SPAN>, "i = " << i ); // We can write more than just - // "Hello World" to the ostream :) + Dout(<SPAN class="highlight">dc::ghost</SPAN>, "i = " << i); // We can write more than just + // "Hello World" to the ostream :) return 0; } </PRE> Index: src/libcwd/documentation/tutorial/tut3.m4 diff -u src/libcwd/documentation/tutorial/tut3.m4:1.4 src/libcwd/documentation/tutorial/tut3.m4:1.5 --- src/libcwd/documentation/tutorial/tut3.m4:1.4 Sun Feb 17 07:30:15 2002 +++ src/libcwd/documentation/tutorial/tut3.m4 Sun Feb 17 16:44:06 2002 @@ -30,7 +30,7 @@ // Set the ostream related with libcw_do to `file': <SPAN class="highlight">Debug( libcw_do.set_ostream(&file) );</SPAN> - Dout( dc::notice, "Hippopotamus are heavy" ); + Dout(dc::notice, "Hippopotamus are heavy"); return 0; } Index: src/libcwd/documentation/tutorial/tut4.m4 diff -u src/libcwd/documentation/tutorial/tut4.m4:1.2 src/libcwd/documentation/tutorial/tut4.m4:1.3 --- src/libcwd/documentation/tutorial/tut4.m4:1.2 Sat Dec 29 20:17:49 2001 +++ src/libcwd/documentation/tutorial/tut4.m4 Sun Feb 17 16:44:06 2002 @@ -21,8 +21,9 @@ <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. The <EM>developer</EM> that uses libcwd will have to use -g++ as compiler and install libraries like libbfd and libiberty, but gets a lot of developing -advantages in return.</P> +g++ as compiler and perhaps use a linux box for the development of the application, but gets a lot +of developing advantages in return. 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"> Index: src/libcwd/documentation/tutorial/tut5.in diff -u src/libcwd/documentation/tutorial/tut5.in:1.4 src/libcwd/documentation/tutorial/tut5.in:1.5 --- src/libcwd/documentation/tutorial/tut5.in:1.4 Sun Feb 17 07:30:15 2002 +++ src/libcwd/documentation/tutorial/tut5.in Sun Feb 17 16:44:06 2002 @@ -66,7 +66,7 @@ The debug channels of libcw are put in namespace <CODE>libcw::debug::channels</CODE>. Nevertheless, it is not necessary to type</P> -<PRE>Dout( libcw::debug::channels::dc::notice, "Hello World" );</PRE> +<PRE>Dout(libcw::debug::channels::dc::notice, "Hello World");</PRE> <P>By default, the macro <CODE>Dout</CODE> et al. automatically include a<CODE> using namespace libcw::debug::channels</CODE>. It is possible to change this default namespace by defining <CODE>DEBUGCHANNELS</CODE> @@ -204,7 +204,7 @@ Debug( libcw_do.on() ); ForAllDebugChannels( if (!debugChannel.is_on()) debugChannel.on() ); - Dout( dc::elephant|dc::owl, "The elephant is called Dumbo, the owl is called Einstein." ); + Dout(dc::elephant|dc::owl, "The elephant is called Dumbo, the owl is called Einstein."); return 0; } @@ -234,7 +234,7 @@ ForAllDebugChannels( if (!debugChannel.is_on()) debugChannel.on() ); <SPAN class="highlight">Debug( dc::elephant.off() );</SPAN> - Dout( dc::elephant|dc::owl, "The elephant is called Dumbo, the owl is called Einstein." ); + Dout(dc::elephant|dc::owl, "The elephant is called Dumbo, the owl is called Einstein."); return 0; } @@ -275,8 +275,8 @@ Debug( libcw_do.on() ); Debug( dc::notice.on() ); - Dout( dc::notice|nonewline_cf, "Hello, " ); - Dout( dc::notice, "World" ); + Dout(dc::notice|nonewline_cf, "Hello, "); + Dout(dc::notice, "World"); return 0; } @@ -303,8 +303,8 @@ Debug( libcw_do.on() ); Debug( dc::notice.on() ); - Dout( dc::notice|nonewline_cf, "Hello, " ); - Dout( dc::notice|<SPAN class="highlight">noprefix_cf</SPAN>, "World" ); + Dout(dc::notice|nonewline_cf, "Hello, "); + Dout(dc::notice|<SPAN class="highlight">noprefix_cf</SPAN>, "World"); return 0; } @@ -361,13 +361,13 @@ struct stat buf; // Warning: this is NOT the correct way to do this (see below) - Dout( dc::notice|nonewline_cf, - "stat(\"" << file_name << "\", " ); + Dout(dc::notice|nonewline_cf, + "stat(\"" << file_name << "\", "); int ret = stat(file_name, &buf); - Dout( dc::notice|noprefix_cf|cond_error_cf(ret != 0), - &buf << ") = " << ret ); + Dout(dc::notice|noprefix_cf|cond_error_cf(ret != 0), + &buf << ") = " << ret); return 0; } @@ -442,13 +442,13 @@ struct stat<SPAN class="highlight">*</SPAN> buf<SPAN class="highlight">p</SPAN>; // This is NOT the correct way to do this. - Dout( dc::notice|nonewline_cf, - "stat_with_buf_alloc(\"" << file_name << "\", " ); + Dout(dc::notice|nonewline_cf, + "stat_with_buf_alloc(\"" << file_name << "\", "); int ret = stat<SPAN class="highlight">_with_buf_alloc</SPAN>(file_name, buf<SPAN class="highlight">p</SPAN>); - Dout( dc::notice|noprefix_cf|cond_error_cf(ret != 0), - bufp << ") = " << ret ); + Dout(dc::notice|noprefix_cf|cond_error_cf(ret != 0), + bufp << ") = " << ret); <SPAN class="highlight"> Debug( dc::malloc.off() ); @@ -514,13 +514,13 @@ char const* file_name = argv[1]; struct stat* bufp; - Dout( dc::notice|<SPAN class="highlight">continued_cf</SPAN>, - "stat_with_buf_alloc(\"" << file_name << "\", " ); + Dout(dc::notice|<SPAN class="highlight">continued_cf</SPAN>, + "stat_with_buf_alloc(\"" << file_name << "\", "); int ret = stat_with_buf_alloc(file_name, bufp); - Dout( <SPAN class="highlight">dc::finish</SPAN>|cond_error_cf(ret != 0), - bufp << ") = " << ret ); + Dout(<SPAN class="highlight">dc::finish</SPAN>|cond_error_cf(ret != 0), + bufp << ") = " << ret); Debug( dc::malloc.off() ); delete bufp; @@ -554,14 +554,14 @@ Debug( libcw_do.<SPAN class="highlight">set_margin</SPAN>("<-- margin -->") ); Debug( libcw_do.<SPAN class="highlight">set_marker</SPAN>("<-- marker -->") ); - Dout( dc::cat|dc::mouse, "The cat chases the mouse." ); - Dout( dc::mouse|dc::elephant, "The mouse chases the elephant." ); - Dout( dc::notice|<SPAN class="highlight">nolabel_cf</SPAN>, "Setting indentation to 8 spaces:" ); - Dout( dc::notice|<SPAN class="highlight">blank_label_cf</SPAN>, "<------>" ); + Dout(dc::cat|dc::mouse, "The cat chases the mouse."); + Dout(dc::mouse|dc::elephant, "The mouse chases the elephant."); + Dout(dc::notice|<SPAN class="highlight">nolabel_cf</SPAN>, "Setting indentation to 8 spaces:"); + Dout(dc::notice|<SPAN class="highlight">blank_label_cf</SPAN>, "<------>"); Debug( libcw_do.<SPAN class="highlight">set_indent(8)</SPAN> ); - Dout( dc::cat, "The cat sleeps." ); - Dout( dc::elephant, "The elephant looks around:" ); - Dout( dc::elephant|<SPAN class="highlight">blank_label_cf|blank_marker_cf</SPAN>, "where did the mouse go?" ); + Dout(dc::cat, "The cat sleeps."); + Dout(dc::elephant, "The elephant looks around:"); + Dout(dc::elephant|<SPAN class="highlight">blank_label_cf|blank_marker_cf</SPAN>, "where did the mouse go?"); return 0; } Index: src/libcwd/documentation/tutorial/tut6.m4 diff -u src/libcwd/documentation/tutorial/tut6.m4:1.4 src/libcwd/documentation/tutorial/tut6.m4:1.5 --- src/libcwd/documentation/tutorial/tut6.m4:1.4 Sun Feb 17 07:30:15 2002 +++ src/libcwd/documentation/tutorial/tut6.m4 Sun Feb 17 16:44:06 2002 @@ -157,6 +157,9 @@ <A HREF="tut5.html#interrupted">interrupting</A> the debug output of the first allocation.</LI> <LI>The allocation is done somewhere inside a function <CODE>main</CODE></A> but no <A HREF="../html/group__group__locations.html">Source-file:Line-number Information</A> information is found.</LI> +<LI>Likely the 'Loading debug symbols from..' is done <EM>before</EM> the application reaches <CODE>main()</CODE> +and is hence invisible (because the debug object, <CODE>libcw_do</CODE>, is still turned off). +You can force libcwd to print it nevertheless by setting the environment variable <CODE>LIBCWD_PRINT_LOADING</CODE>.</LI> </UL> <TABLE> ----------------------- End of diff ----------------------- |