Link to home
Start Free TrialLog in
Avatar of longjumps
longjumps

asked on

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

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
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

When you select the DEBUG (as opposed to RELEASE) build then it is already defined for you.
>>Where it prints?

If you use a TRACE command it prints to the output window (which is in visual studio)
Avatar of longjumps
longjumps

ASKER

How to use Trace command?
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
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?
Build it as a debug build (see my original comment).User generated imageUser generated image
I don't see "Active Debug".

What should I do?

See attachment.
vs2010-no-active-debug.png
In my snapshot there are only two project configurations defined.  Debug and Release.  That show the currently selected (=active) one is debug.
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.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
But how to define DEBUG not from code, but compile variable?
You can't.
It is a compiler directive to modify how code is compiled.
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?
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).
checking the solution