Print your first line of debug output.
The smallest C++ program that prints ยซHello Worldยป as debug output to cerr is:
Each of the lines of code in this first example program are explained below.
This header file contains all definitions and declarations that are needed for debug output. For example, it defines the macros Debug and Dout and declares the debug object libcw_do and the debug channel dc::notice.
FAQ
This call checks that the libcwd header files that are being used belong to the libcwd.so shared object that the application linked with. It is also required before any debug info can be loaded of the respective loaded shared objects.
This turns on the Debug Channel dc::notice. Without this line, the code Dout(dc::notice, "Hello World") would output nothing: all Debug Channels are off by default, at start up.
FAQ
This turns on the Debug Object libcw_do. Without this line, the code Dout(dc::notice, "Hello World") would output nothing: all Debug Objects are off by default, at start up.
A Debug Object is related to exactly one ostream. libcwd defines only one Debug Object by itself (being libcw_do), this is enough for most applications. The default ostream is cerr. Using the macro Dout causes debug output to be written to libcw_do.
FAQ
This outputs "Hello World" to the ostream currently related to libcw_do provided that the Debug Channel dc::notice is turned on.
Output is written as if everything in the second field of the macro Dout is written to an ostream; it is "equivalent" with: cerr << "Hello World" << '\n';
FAQ
Continue with Tutorial 2: Creating Your Own Debug Channels.