472,791 Members | 981 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

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 3957
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dmitry Karneyev | last post by:
Hi! Does anyone know how to adjust (if it's possible) VS to copy a file from one directory to another before debugging program? Thanks.
16
by: Geoff Jones | last post by:
Hi Can anybody help me with the following, hopefully simple, question? I have a table which I've connected to a dataset. I wish to add a new column to the beginning of the table and to fill...
4
by: Saurabh Aggrawal | last post by:
Hi, I have made a dll and it is working fine in the debug build (as expected) but when I run it in the release build it is working strangely. For example, the dll saves the 10 properties on the...
3
by: _DS | last post by:
The two obvious methods for ref'ing assemblies are: Add a reference and 'Browse' for the actual DLL OR Add existing project to the solution, then add a ref to 'Project'. 1: I'd like to...
1
by: DH | last post by:
I have an untyped dataset with a table. I am trying to programmatically add a row to this table. This was working in VS 2003 / .net 1.1 I am receiving an error "Object reference not set to an...
7
by: moondaddy | last post by:
I'm running a wpf windows app and want to add the appSettings element to the config file. when I do, the app wont start up and I get the following error: {"The type initializer for...
0
by: =?Utf-8?B?QW5keSBZdQ==?= | last post by:
Hi, I'm trying to return exceptions from a WCF Service using FaultExceptions. I got the service compiled and running. But I get an error while adding a service reference to it. The error reads: "...
3
by: Chris Shenton | last post by:
I am setting up handlers to log DEBUG and above to a rotating file and ERROR and above to console. But if any of my code calls a logger (e.g., logging.error("foo")) before I setup my handlers, the...
10
by: Guillermo_Lopez | last post by:
Hello All, I am using VBA in access to perform some calculations. There is a particular sumation that is wrong (barely). this code is withing a loop. TDist = TDist + TempDist Both TDist...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.