Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
The standard assert does not work nice in C++ Builder when working on a console application. Instead, one can use the code below, which does wait for a key press.
* View the code of 'Assert' in plain text.
//---------------------------------------------------------------------------
#ifndef BilderbikkelConsoleAssertH
#define BilderbikkelConsoleAssertH
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/CppBuilderAssert.htm
#ifdef NDEBUG
#define Assert(x) ((void)0)
#else
#include <iostream>
#define Assert(x) \
if (! (x)) \
{ \
std::cout \
<< "ERROR!! Assertion " \
<< std::string (#x) \
<< " failed\n on line " \
<< (__LINE__) \
<< " in the function " \
<< (__FUNC__) \
<< "\n in file " \
<< __FILE__ \
<< std::endl; \
std::string tempString; \
std::getline(std::cin,tempString); \
}
#endif
#endif
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.