netcdf-c/libcdmr/crdebug.h

45 lines
1.2 KiB
C
Raw Normal View History

2010-12-16 05:45:05 +08:00
/*********************************************************************
* Copyright 1993, UCAR/Unidata
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
* $Header: /upc/share/CVS/netcdf-3/libncdap3/dapdebug.h,v 1.33 2009/12/03 18:53:16 dmh Exp $
*********************************************************************/
#ifndef CRDEBUG_H
#define CRDEBUG_H
2011-06-11 02:47:26 +08:00
#undef DEBUG
2010-12-16 05:45:05 +08:00
#include <stdarg.h>
#include <assert.h>
/* Warning: setting CATCHERROR has significant performance impact */
#undef CATCHERROR
#ifdef DEBUG
#undef CATCHERROR
#define CATCHERROR
#endif
#define PANIC(msg) assert(nccrpanic(msg));
#define PANIC1(msg,arg) assert(nccrpanic(msg,arg));
#define PANIC2(msg,arg1,arg2) assert(nccrpanic(msg,arg1,arg2));
#define ASSERT(expr) if(!(expr)) {PANIC(#expr);} else {}
extern int nccrpanic(const char* fmt, ...);
#define MEMCHECK(var,throw) {if((var)==NULL) return (throw);}
#ifdef CATCHERROR
2011-06-11 02:47:26 +08:00
/* Place breakpoint on nccrbreakpoint to catch errors close to where they occur*/
2010-12-16 05:45:05 +08:00
#define THROW(e) nccrthrow(e)
#define THROWCHK(e) (void)nccrthrow(e)
extern int nccrbreakpoint(int err);
extern int nccrthrow(int err);
#else
#define THROW(e) (e)
#define THROWCHK(e)
#endif
#endif /*CRDEBUG_H*/