stanigator
stanigator

Reputation: 10944

Visual Studio disable TRACE in debug mode

For a C++ project that I'm developing in Visual Studio 2005, I would like to disable the TRACE output option while running the code in debug mode. I have searched the internet about how to achieve this, but no luck. Is this even easily achievable? If so, how? Thanks in advance.

Update #1:

#define     USETRACE        0
#if !USETRACE && DEBUG
    #undef TRACE
    #define TRACE(x)
#endif

I tried the above code in debug mode, near the very top of stdafx.h, but TRACE is still outputting to the debug output. It would be great if suggestions on what's wrong with my implementation are provided so that I can fix it. Thanks.

Upvotes: 1

Views: 4583

Answers (2)

stanigator
stanigator

Reputation: 10944

Used the difficult way first few times, this is what I end up doing:

#if USETRACE
    #define PRINT TRACE
#else
    #define PRINT
#endif

Upvotes: 0

JaredPar
JaredPar

Reputation: 755121

It turns out there is a much simpler way to do this, set global variable afxTraceEnabled to false

afxTraceEnabled = false;

Reference

Upvotes: 3

Related Questions