1 /* 2 * Copyright (C) 2001-2012 Jacek Sieka, arnetheduck on gmail point com 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 */ 18 19 #pragma once 20 21 #include <cstdio> 22 23 #ifdef _DEBUG 24 25 #include <cassert> 26 27 #define dcdebug printf 28 #ifdef _MSC_VER 29 30 #include <crtdbg.h> 31 32 #define dcassert(exp) \ 33 do { if (!(exp)) { \ 34 dcdebug("Assertion hit in %s(%d): " #exp "\n", __FILE__, __LINE__); \ 35 if(1 == _CrtDbgReport(_CRT_ASSERT, __FILE__, __LINE__, NULL, #exp)) \ 36 _CrtDbgBreak(); } } while(false) 37 #else 38 #define dcassert(exp) assert(exp) 39 #endif 40 #define dcdrun(exp) exp 41 #else //_DEBUG 42 #define dcdebug if (false) printf 43 #define dcassert(exp) 44 #define dcdrun(exp) 45 #endif //_DEBUG 46