News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Debug TRACE macro equivalent

Started by 12oclocker, November 01, 2010, 11:28:11 PM

Previous topic - Next topic

12oclocker

visual studio MFC style trace macro, I added one to code blocks, see below post for instructions on how to impliment...  :D

12oclocker

#1
I wrote a drop in TRACE macro for codeblocks   :D



/////////////////////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///////////////////