Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: 12oclocker on November 01, 2010, 11:28:11 pm

Title: Debug TRACE macro equivalent
Post by: 12oclocker on November 01, 2010, 11:28:11 pm
visual studio MFC style trace macro, I added one to code blocks, see below post for instructions on how to impliment...  :D
Title: Re: Debug TRACE macro equivalent
Post by: 12oclocker on November 02, 2010, 02:47:41 am
I wrote a drop in TRACE macro for codeblocks   :D

Code

/////////////////////BEGIN TraceEx.h HEADER FILE///////////////////////
//
// In codeblocks, go to "project->build options" select "Debug" in the left list window,
// then in the "#defines" tab add the value "DEBUG=1"
//
//
#ifndef TRACEEX1
#define TRACEEX1


#ifdef DEBUG
#define DEBUG_ON
#endif

#ifdef _DEBUG
#ifndef DEBUG_ON
#define DEBUG_ON
#endif
#endif

#ifdef DEBUG_ON
#include <stdio.h>
#define TRACE(x...) printf(x);//catch semicolon
#else
#define TRACE(x...) //do nothing with x
#endif



#endif
/////////////////////END TraceEx.h HEADER FILE///////////////////////



/////////////////EXAMPLE OF HOW TO USE TRACE MACRO///////////////////

//add your include file, at Release build time this file will compile to an empty file and get discarded
#include "TraceEx.h"

//do NOT put a semicolon at the end of your trace macro (we put in the define for you)
//though if you forget, and put a semicolon, the function seems to work on in release and debug ok
//when compiled in release mode this line will complile to a BLANK line
TRACE("%s","this is a trace test")

//////////////END EXAMPLE OF HOW TO USE TRACE MACRO///////////////////