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
Visual C++.NETWindows Server 2008

Avatar of undefined
Last Comment
longjumps

8/22/2022 - Mon
AndyAinscow

When you select the DEBUG (as opposed to RELEASE) build then it is already defined for you.
AndyAinscow

>>Where it prints?

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

ASKER
How to use Trace command?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
AndyAinscow

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
longjumps

ASKER
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?
AndyAinscow

Build it as a debug build (see my original comment).Possibile build choices - Debug and ReleaseDEBUG is defined for you in a debug build
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
longjumps

ASKER
I don't see "Active Debug".

What should I do?

See attachment.
vs2010-no-active-debug.png
AndyAinscow

In my snapshot there are only two project configurations defined.  Debug and Release.  That show the currently selected (=active) one is debug.
longjumps

ASKER
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.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
AndyAinscow

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
longjumps

ASKER
But how to define DEBUG not from code, but compile variable?
AndyAinscow

You can't.
It is a compiler directive to modify how code is compiled.
longjumps

ASKER
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?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
AndyAinscow

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).
longjumps

ASKER
checking the solution