|
From: Mark L. <mli...@ip...> - 2003-10-11 05:23:34
|
On Thu, 09 Oct 2003 16:27:45 +0200 Wobien <wo...@pl...> wrote:
W> Using assert is supposed to be a big help in finding bugs in your program.
W>
W> #include <cassert>
W> assert(a<b);
W>
W> should stop your program if a>=b and print the file and line number of the
W> assert statement that failed, if and only if you run in debug mode. If you
W> are not in debug mode, the assert statements should not be compiled.
W>
W> Now I have 2 problems:
W>
W> 1: my program stops if the assert fails, even if I did not compile in the
W> debug mode.
Wrap it in some compile time checked #defines.
W> 2: when the program stops it does not wait and stop to give me the
W> opportunity to read the message about the file and line number. The system
W> ("PAUSE"); statement at the end of the main procedure does not help here,
W> because the program never gets there.
W>
W> A simple test "program" to try this is:
W>
W> #include <stdlib.h>
W> #include <cassert>
W> int main()
W> {
W> int a=5;
W> int b=1;
W> assert(a<b);
W> system ("PAUSE");
W> return 0;
W> }
Would you accept "start using wxWindows then you can have more intelligent
assert processing / logging" as an answer? ;-) Thereagain, you are using C and
not C++ so that may not be such a good answer anyway.
MarkL
|