|
From: Wobien <wo...@pl...> - 2003-10-10 21:14:15
|
Thanks Daniel and others for your suggestions.
The #define NDEBUG suggested by jo mateix works fine to prevent the
assertions to compile.
I already tried to run my program from the DOS prompt, but I did it by
closing Windows and start computer in DOS mode. When I do that I get "This
program cannot be run in the DOS mode".
When I do it the way Daniel suggests it works fine, and I can read the
message.
Wobien
----- Original Message -----
From: "Daniel Glenfield" <sp...@ho...>
To: <wo...@pl...>
Sent: Friday, October 10, 2003 11:54 AM
Subject: Re: [Dev-C++] using assert
> Try something like
>
> #if DEBUG
> assert(a<b);
> #endif
>
> and see if that does anything when compiling in Release mode.
>
> As for the irritating closing of the console window you'll need to run the
> program from a dos prompt.
>
> So do Start -> Accessories -> Command Prompt (it all depends on what OS
you
> have - in ME it is in Start itself).
> Type
> cd C:\Dev-CPP\MyTest\ <--- this is where the exe is
>
> then type
> MyTestProgram.exe
>
> That should work.
>
> Daniel
>
>
> >From: Wobien <wo...@pl...>
> >Reply-To: Wobien <wo...@pl...>
> >To: dev-cpp-users-list <dev...@li...>
> >Subject: [Dev-C++] using assert
> >Date: Thu, 09 Oct 2003 16:27:45 +0200
> >
> >Using assert is supposed to be a big help in finding bugs in your
program.
> >
> >#include <cassert>
> >assert(a<b);
> >
> >should stop your program if a>=b and print the file and line number of
the
> >assert statement that failed, if and only if you run in debug mode. If
you
> >are not in debug mode, the assert statements should not be compiled.
> >
> >Now I have 2 problems:
> >
> >1: my program stops if the assert fails, even if I did not compile in the
> >debug mode.
> >
> >2: when the program stops it does not wait and stop to give me the
> >opportunity to read the message about the file and line number. The
system
> >("PAUSE"); statement at the end of the main procedure does not help here,
> >because the program never gets there.
> >
> >A simple test "program" to try this is:
> >
> >#include <stdlib.h>
> >#include <cassert>
> >int main()
> >{
> > int a=5;
> > int b=1;
> > assert(a<b);
> > system ("PAUSE");
> > return 0;
> >}
> >
> >
> >
> >-------------------------------------------------------
> >This SF.net email is sponsored by: SF.net Giveback Program.
> >SourceForge.net hosts over 70,000 Open Source Projects.
> >See the people who have HELPED US provide better services:
> >Click here: http://sourceforge.net/supporters.php
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
> _________________________________________________________________
> Stay in touch with absent friends - get MSN Messenger
> http://www.msn.co.uk/messenger
>
|