Added wassert(), a assert()-like function forcing a crash.

Replaced every assert() with wassert()
This commit is contained in:
Isaac Clerencia Perez 2004-12-31 21:01:37 +00:00
parent dbabdcd096
commit 46c0883151
2 changed files with 41 additions and 0 deletions

24
src/wassert.cpp Normal file
View file

@ -0,0 +1,24 @@
/*
Copyright (C) 2005 by Isaac Clerencia <isaac@sindominio.net>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#include "log.hpp"
#include <iostream>
void wassert(bool expression)
{
// crash if expression is false
if(! expression) {
lg::err(lg::general) << "Assertion failure" << "\n";
*reinterpret_cast<int*>(0) = 5;
}
}

17
src/wassert.hpp Normal file
View file

@ -0,0 +1,17 @@
/*
Copyright (C) 2005 by Isaac Clerencia <isaac@sindominio.net>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
#ifndef WASSERT_HPP_INCLUDED
#define WASSERT_HPP_INCLUDED
void wassert(bool expression);
#endif