From f329ee2b4cfdde656d2fe30f2a2789d8a3774203 Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Thu, 6 Oct 2016 16:07:35 -0600 Subject: cleanup --- lib/codegen/include/code_gen/CGdebug.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/codegen/include/code_gen/CGdebug.h (limited to 'lib/codegen/include/code_gen/CGdebug.h') diff --git a/lib/codegen/include/code_gen/CGdebug.h b/lib/codegen/include/code_gen/CGdebug.h new file mode 100644 index 0000000..cf72c36 --- /dev/null +++ b/lib/codegen/include/code_gen/CGdebug.h @@ -0,0 +1,31 @@ +#ifndef CGDEBUG_H +#define CGDEBUG_H + +#include +#include +#include + +#ifndef NDEBUG // means that CMAKE_BUILD_TYPE=Debug +#define DEBUGCODEGEN +#endif +// This thing below potentially create leaks +#define FILENAME basename(strdup(__FILE__)) + +#ifdef DEBUGCODEGEN +#define CG_DEBUG_PRINT(format,args...) fprintf(stderr,"%15s | %15s | LN%-4d:\t" format,FILENAME,__FUNCTION__, \ + __LINE__, ##args ) +#define CG_DEBUG_BEGIN { \ + fprintf(stderr,"=========\t%15s, %15s, LN%-4d\t=========\n",FILENAME,__FUNCTION__,__LINE__); +#define CG_DEBUG_END fprintf(stderr,"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");} +#else +#define CG_DEBUG_PRINT(format,args...) do {} while(0) /* Don't do anything */ +#define CG_DEBUG_BEGIN while(0) { +#define CG_DEBUG_END } +#endif + +// TODO below should be substituted by some error throwing? to be more consistent with cpp style +#define CG_ERROR(format,args...) fprintf(stderr,"ERROR:\t%s, %s, LN%d:\t" format,FILENAME,__FUNCTION__, \ + __LINE__, ##args ) + + +#endif -- cgit v1.2.3-70-g09d2