Solved

MS VS 2010 C++ project - how to define DEBUG var?

Posted on 2012-12-30
15
434 Views
Last Modified: 2013-04-18
I have project and imported source regex.c

In this source I have
# ifdef DEBUG
.....


How to add this to project in order to get debugging information?

Where it prints?

Sources are attached.
regex.c
xregex.h
0
Comment
Question by:longjumps
  • 8
  • 7
15 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
When you select the DEBUG (as opposed to RELEASE) build then it is already defined for you.
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
>>Where it prints?

If you use a TRACE command it prints to the output window (which is in visual studio)
0
 
LVL 1

Author Comment

by:longjumps
Comment Utility
How to use Trace command?
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
eg.
      TRACE(_T("In put your function/class/whatever here"));

or
        TRACE(s);  //s is a string variable, eg with the value of some other variable in it
0
 
LVL 1

Author Comment

by:longjumps
Comment Utility
The question was related to
# ifdef DEBUG

and in the source I have already debugging printings like
DEBUG_PRINT1 ...

and others.

So the question is how should I compile and run this code in Visual Studio 2010 to see the existing printing and not adding new TRACEs?
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
Build it as a debug build (see my original comment).Possibile build choices - Debug and ReleaseDEBUG is defined for you in a debug build
0
 
LVL 1

Author Comment

by:longjumps
Comment Utility
I don't see "Active Debug".

What should I do?

See attachment.
vs2010-no-active-debug.png
0
Shouldn't all users have the same email signature?

You wouldn't let your users design their own business cards, would you? So, why do you let them design their own email signatures? Think of the damage they could be doing to your brand reputation! Choose the easy way to manage set up and add email signatures for all users.

 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
In my snapshot there are only two project configurations defined.  Debug and Release.  That show the currently selected (=active) one is debug.
0
 
LVL 1

Author Comment

by:longjumps
Comment Utility
Dear, if I need something define or add, please advice how.

I simply wants that in the lib code I compile and run get debugging printing, using already existing in the code

# ifdef DEBUG
.....

DEBUG_PRINT1 ...

and others.

I attached lib code to the original question.

Please advice.
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
Comment Utility
The following will define a symbol called DEBUG
#define DEBUG

(but for a debug build it is already defined so you do not need to do anything)


ps.  You can add that line of code to .h files or .cpp files anywhere you wish.  The symbol is only visible to the compiler AFTER it is defined.
0
 
LVL 1

Author Comment

by:longjumps
Comment Utility
But how to define DEBUG not from code, but compile variable?
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
You can't.
It is a compiler directive to modify how code is compiled.
0
 
LVL 1

Author Comment

by:longjumps
Comment Utility
such precompiler directive should be pass from outside of code by compiler.
in Linux there is something -D<var>  can I do such thing in Win?
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
You can define things in the command line to the compiler BUT it is not a variable.  They determine which blocks of code are compiled or not.  (See the project settings).
0
 
LVL 1

Author Comment

by:longjumps
Comment Utility
checking the solution
0

Featured Post

Want to promote your upcoming event?

Attending an event? Speaking at a conference? Or exhibiting at a tradeshow? Easily inform your contacts by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
A safe way to clean winsxs folder from your windows server 2008 R2 editions
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now