Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2012-12-30
15
Medium Priority
?
466 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 45

Expert Comment

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

Expert Comment

by:AndyAinscow
ID: 38731125
>>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
ID: 38731186
How to use Trace command?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 45

Expert Comment

by:AndyAinscow
ID: 38731250
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
ID: 38732039
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 45

Expert Comment

by:AndyAinscow
ID: 38732137
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
ID: 38732167
I don't see "Active Debug".

What should I do?

See attachment.
vs2010-no-active-debug.png
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 38732258
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
ID: 38734073
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 45

Accepted Solution

by:
AndyAinscow earned 2000 total points
ID: 38734145
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
ID: 38734436
But how to define DEBUG not from code, but compile variable?
0
 
LVL 45

Expert Comment

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

Author Comment

by:longjumps
ID: 38827232
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 45

Expert Comment

by:AndyAinscow
ID: 38827345
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
ID: 38884353
checking the solution
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

618 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