[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppVclAssert
Because in C++ Builder a program's window immediatly closes when using an ordinary assert, I provide an assert statement more practical in C++ Builder below.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppVclAssert
(C++ VCL) assert
See assert for the rationale of an assert statement.Because in C++ Builder a program's window immediatly closes when using an ordinary assert, I provide an assert statement more practical in C++ Builder below.
//#define this if you want to have a pure STL application
- ifndef __BILDERBIKKEL_ASSERT_HPP
- define __BILDERBIKKEL_ASSERT_HPP
- ifdef BILDERBIKKEL_USE_STL_ONLY
- ifdef NDEBUG
- define Assert(x) ((void)0)
- else //Else of: #ifdef NDEBUG
- include <iostream>
if (! (x)) \ { \ std::cout \ << "ERROR!! Assertion " << #x \ << " failed\n"; \ << " on line " << __LINE__ << "\n"; \ << " in file " << __FILE__ << "\n"; \ std::cin.get(); \ std::exit(1); \ }
- define Assert(x) \
- endif //End of: #ifdef NDEBUG
- else //Else of: #ifdef BILDERBIKKEL_USE_STL_ONLY
- ifdef NDEBUG
- define Assert(x) ((void)0)
- else //Else of: #ifdef NDEBUG
- include <Dialogs.hpp> //For ShowMessage
if (! (x)) \ { \ ShowMessage( \ "ERROR!! Assertion " \ + String (#x) \ + " failed\n on line " \ + (__LINE__) \ + "\n in file " \ + (__FILE__) \ ); \ }
- define Assert(x) \
- endif //End of: #ifdef NDEBUG
- endif //Else of: #ifdef BILDERBIKKEL_USE_STL_ONLY
- endif //End of: #ifndef __BILDERBIKKEL_ASSERT_HPP
'Assert' links
Code links
- #include
- __LINE__
- __FILE__
- include
- iostream (header file)
- Preprocessor and preprocessor statements
- String
- ShowMessage
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
