File: channel.cc

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 (33 lines) | stat: -rw-r--r-- 1,237 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
// Compile as: g++ -g -DCWDEBUG channel.cc -lcwd [-lbfd -liberty [-ldl]]
// Please see the "example-project" in the source distribution of libcwd
// for a better Real Life example.

//-------------------------------------------------------------------------------
// This block should really be part of custom header files!  Please ignore it
// and read documentation/reference-manual/preparation.html#preparation_step2 instead.
// "sys.h":
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <libcwd/sys.h>
#define DEBUGCHANNELS ::example		      // Where we'll put our namespace dc
// "debug.h":
#include <libcwd/debug.h>
//-------------------------------------------------------------------------------

namespace example {                           // namespace dc cannot be put in ::
  namespace dc {
    libcwd::channel_ct ghost("GHOST");  // Create our own Debug Channel
  }
}

int main(void)
{
  Debug( dc::ghost.on() );                    // Remember: don't forget to turn
  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
					      // "Hello World" to the ostream :)
  return 0;
}