License Public Domain
Lines 10
Keywords
cout (1) debug (6) dout (1)
Permissions
Viewable by Everyone
Editable by All Siafoo Users
Hide
Bored? Check out the Recent Activity on Siafoo Join Siafoo Now or Learn More

dout Atom Feed 2

In Brief dout is cout except that whenever it is used, it prints the filename and the line number along with the dout statement. It is great for debugging, especially when using multiple files in a project. Because it uses ANSI/ISO C/C++ Standard Predefined Macros this code should work on any C/C++ compiler.... more
# 's
 1#if !defined(DoutH)
2#define DoutH
3
4#if !defined(_DOUT_QUIET)
5#define ccout cout
6#define dout cout << __FILE__ << "(" << __LINE__ << ") "
7#else
8#define ccout if(0)cout
9#define dout if(0)cout
10#endif
11
12#endif

dout is cout except that whenever it is used, it prints the filename and the line number along with the dout statement. It is great for debugging, especially when using multiple files in a project. Because it uses ANSI/ISO C/C++ Standard Predefined Macros this code should work on any C/C++ compiler.

For example the statement

std::dout << "debug data" << std::endl

on line 100 of myfile.cc would print:

myfile.cc(100) debug data