468,512 Members | 1,338 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Adding debug message

Hi,
I am new to C++, But has good experience in C. In C I have used
macros to enable / disable debug statements in the code. For ex :

#if defined ENABLE_DEBUG
#define Printf1(arg) printf(arg)
#else
#define Printf1(arg)
#endif

int main()
{
Printf1("This is a debug statement\n");
}

By defining/not-defining ENABLE_DEBUG I can enable / disable the debug
statements.
I would like to know what is the kind of standard used in C++ to
enable / disable the debug statements(ie cout statements).

Jan 28 '08 #1
2 3676
mthread a écrit :
Hi,
I am new to C++, But has good experience in C. In C I have used
macros to enable / disable debug statements in the code.
[snip]

I would like to know what is the kind of standard used in C++ to
enable / disable the debug statements(ie cout statements).
There is no standard way. But there are libraries that can spare you the
effort of reinventing the wheel. Google for them (an example is
Log4cpp:http://log4cpp.sourceforge.net/).
IIRC there was a stub of log library in Boost also (in the vault).

Michael
Jan 28 '08 #2
Michael DOUBEZ wrote:
IIRC there was a stub of log library in Boost also (in the vault).
Version 2 of John Torjo's Boost Logging Library comes up for review in about
a week. See http://torjo.com/log2/ for more.
--
Chuck
Jan 29 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Dmitry Karneyev | last post: by
16 posts views Thread by Geoff Jones | last post: by
3 posts views Thread by _DS | last post: by
reply views Thread by =?Utf-8?B?QW5keSBZdQ==?= | last post: by
10 posts views Thread by Guillermo_Lopez | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.