#ifndef TRACE_H
#define TRACE_H
#include <stdio.h>
#define STRING_EXPAND(S) #S
#define STRINGIZE(S) STRING_EXPAND(S)
#ifdef __GNU_C__
# define TRACE Trace trace( __FILE__, __LINE__, __PRETTY_FUNCTION__ )
#else
# ifdef WIN32 /* XXX Need better test for VisualC++ */
# define TRACE Trace trace( __FILE__, __LINE__, __FUNCSIG__ )
# else
# define TRACE Trace trace( __FILE__, __LINE__, "File: " __FILE__ " Line: " STRINGIZE(__LINE__) )
# endif
#endif
class Trace
{
public:
Trace(const char *file, int line, const char *function) : mFile(file), mLine(line), mFunction(function) {
printf("%s entered\n", mFunction);
}
~Trace() {
printf("%s leaving\n", mFunction);
}
const char *mFile;
int mLine;
const char *mFunction;
};
#endif // TRACE_H