Mail Archives: djgpp/1998/09/07/20:00:24
From: | wjae AT plex DOT nl (Wiel Aerts)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Help!!!, using exceptions.
|
Date: | Sat, 05 Sep 1998 16:33:42 GMT
|
Organization: | Plex -- a public access Internet provider
|
Lines: | 60
|
Message-ID: | <35f16683.1987865@news.plex.nl>
|
References: | <35f041dc DOT 1315962 AT MERCURIO>
|
NNTP-Posting-Host: | news.plex.nl
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
On Fri, 04 Sep 1998 19:45:41 GMT, igp AT vlc DOT servicom DOT es (Ignacio García
Pérez) wrote:
>Hi,
>
>I just began today my very-first-stupid-program in C++ using
>exceptions. I so simple just to check that the exception handling
>mechanism is working.
>
>Well, it doesn't work. I compiled it using GCC 2.81, compiles with no
>complaints but when I execute it, exits with an "Abort!" message when
>the exception is thrown:
>
>#include <stdio.h>
>
>void Test(int E) {
> puts("Test-BEGIN");
> if (E) throw (E);
> puts("Test-END");
> }
>
>void main(void) {
>
> puts("main-BEGIN");
>
> try { Test(1); }
>
> catch (int E) { puts("catch (int E)"); }
> catch (...) { puts("catch (...)"); }
>
> puts("main-END");
> }
>
>The output is:
>"main-BEGIN"
>"Test-BEGIN"
>"Abort!"
>
>
>As you can see, even if I was doing something wrong that caused the
>integer exception not to be caught by the first "catch" block, the
>next "catch(...)" should catch ALL exceptions.
>
>Any clues will be greatly appreciated.
>
>Thanks. Nacho.
I just copied your code and compiled (g++ main.cc, djgpp 2.8.1),
the output was (as you expected):
main-BEGIN
Test-BEGIN
catch (int E)
main-END
Something wrong with your installation? May be you should compile
with: g++ -v main.cc to get more information, and post it (so the
real guru's can figure out what is wrong)
Good luck,
Wiel
- Raw text -