[ create a new paste ] login | about

Project: xow
Link: http://xow.codepad.org/ewrAS2eS    [ raw code | fork ]

GHF - C++, pasted on Nov 19:
/*
 * affirm.h
 *
 *  Created on: Jul 21, 2009
 *      Author: Xo
 */

#ifndef AFFIRM_H_
#define AFFIRM_H_

#ifdef DEBUG
#include <iostream>
#include <cstdlib>

#define affirmStringify(p) #p
#define affirmMacroStringify(p) affirmStringify(p)
#define affirmLine affirmMacroStringify(__LINE__)
#define affirmFileError "[" __FILE__ ":" affirmLine "] "
#define affirm(exp, msg) _affirm(exp, affirmFileError msg)

inline void _affirm(bool expression, const char *message = "Raxo: Error - a runtime condition failed") {
	if(!expression) {
		std::cerr << message << '\n';
		exit(EXIT_FAILURE);
	}
}

#define assure(e) if(!(e))
#else
inline void affirm(bool expression, const char *msg = "") { }

#define assure(e) if(false)
#endif

#endif /* AFFIRM_H_ */


Create a new paste based on this one


Comments: