assert_removed.h.svn-base

来自「Complete support for EBNF notation; Obje」· SVN-BASE 代码 · 共 46 行

SVN-BASE
46
字号
// assert.h is a bad name -- it collides with standard header and// under certain settings gets included from <cassert>// a C++ exception-throwing <assert.h> replacement.#ifndef __WHALE__ASSERT_H#define __WHALE__ASSERT_H#undef _ASSERT_H#define _ASSERT_H		// to prevent standard assert.h inclusion#include <iostream>class FailedAssertion{public:	int line;	char *fn;	char *condition;	FailedAssertion(int supplied_line, char *supplied_fn, char *supplied_condition)	{		line=supplied_line;		fn=supplied_fn;		condition=supplied_condition;	}};#undef assert#ifdef NDEBUG	#define assert(condition) (condition ? true : false)#else	#define assert(condition) ((condition) ? true : assert_proc(__LINE__, __FILE__, #condition))#endifinline bool assert_proc(int line, char *fn, char *condition){	std::cout << "\nAssertion failed: " << condition << ", file " << fn		<< ", line " << line << ".\n";	throw *new FailedAssertion(line, fn, condition);	return false; // to please the compiler}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?