User forums > General (but related to Code::Blocks)

Debug TRACE macro equivalent

(1/1)

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

12oclocker:
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///////////////////

--- End code ---

Navigation

[0] Message Index

Go to full version