Author Topic: Debug TRACE macro equivalent  (Read 10022 times)

12oclocker

  • Guest
Debug TRACE macro equivalent
« 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
« Last Edit: November 02, 2010, 03:01:39 am by 12oclocker »

12oclocker

  • Guest
Re: Debug TRACE macro equivalent
« Reply #1 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///////////////////
« Last Edit: November 02, 2010, 03:12:46 am by 12oclocker »