www.pudn.com > cppcc.rar > debug.h
/*
* File: debug.h
* $Id: debug.h,v 1.4 2002/04/29 09:34:10 alec Exp $
*
* Author: Alec Panovici (alecu@email.com)
* Copyright
*
* Comments: debug support. Both C and C++ versions. This uses the DEBUG
* macro from config.h.
*
* Revision history:
*
* $Log: debug.h,v $
* Revision 1.4 2002/04/29 09:34:10 alec
* scanner ptree building compiles
*
*/
#ifndef __DEBUG_H__
#define __DEBUG_H__
#include "../config.h"
#ifdef DEBUG
#if defined __cplusplus
#define ASSERT(x, y) {if (!(x)) { cerr << "ASSERTION FAILED @" << __FILE__ << ":" << __LINE__ << ": " << (y) << endl; cerr.flush(); abort(); }}
#define UNIMPLEMENTED {cerr << "UNIMPLEMENTED @" << __FILE__ << ":" << __LINE__ << endl; cerr.flush(); abort(); }
#else
#include
#define ASSERT(x, y) {if(!(x)) { fprintf(stderr, "ASSERTION FAILED @%s:%d: %s\n", __FILE__, __LINE__, y); fflush(stderr); abort(); }}
#define UNIMPLEMENTED { fprintf(stderr, "UNIMPLEMENTED @%s:%d\n", __FILE__, __LINE__); fflush(stderr); abort(); }}
#endif /* __cplusplus */
#else /* no DEBUG */
#define ASSERT(x, y)
#define UNIMPLEMENTED
#endif /* DEBUG */
#if defined __cplusplus
#define RUNTIME_ERROR(x) { cerr << "RUNTIME ERROR @" << __FILE__ << ":" << __LINE__ << ": " << (x) << endl; cerr.flush(); abort(); }
#else
#define RUNTIME_ERROR(x) { fprintf(stderr, "RUNTIME ERROR @%s:%d: %s\n", __FILE__, __LINE__, x); fflush(stderr); abort(); }
#endif
#endif /* #ifndef __DEBUG_H__ */