Article View: gnu.gcc.help
Article #46417C++ Exception Handling
From: Mark Wirt
Date: Thu, 24 Nov 1994 12:15
Date: Thu, 24 Nov 1994 12:15
48 lines
2291 bytes
2291 bytes
I have a question, which, I believe, will have a simple answer. I'm
trying to use C++ exception handling with GNU gcc (version 2.5.8,
libg++ 2.5.3) under Linux, but I'm running into difficulties. As an
example, if I try to compile code containing the following fragment:
int my_func(void)
{
int i = 1;
cout <<"this is this is this\n";
throw 1; //<-Offending line, #28
return(i);
}
... I receive the following error messages:
g++ test.cc -o test
test.cc: In function `int my_func()':
test.cc:28: warning: `catch', `throw', and `try' are all C++ reserved words
test.cc:28: `throw' undeclared (first use this function)
Well, *I* know that they're reserved words, the compiler seems to know
it, but It refuses to take them seriously. I've tried many different
ways to get the compiler to accept this code -- all to no avail. I
can imagine several reasons:
1) Something is wrong with my syntax (in which case this message
doesn't really belong in this group). In all fairness, I'm new to
exception handling, and I cannot find any documentation to these
features in the online documentation (info, man, etc.), so this is a
real possibility.
2) The compiler knows about try, catch, and throw, but it doesn't
support them. Again, I can't find anything in the documentation to
support this contention one way or another.
3) The compiler *does* support these constructs, but I have to enable
these features with some switch of which I am unaware.
4) Evil demons inhabit my computer.
5) Etc.
Any help would be appreciated.
Thanks!
Mark
Technical Details
Message-ID:
<wirt.38.000C4264@cais.cais.com>Path:
arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!howland.reston.ans.net!pipex!uunet!news.cais.com!wwirt.cais.com!wirtShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,bedd89dcf78cdc8f,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1994-11-24 09:21:59 PST Path: arc1-ca.pugleaf.net!bga.com!news.sprintlink.net!howland.reston.ans.net!pipex!uunet!news.cais.com!wwirt.cais.com!wirt From: wirt@cais.cais.com (Mark Wirt) Newsgroups: gnu.gcc.help Subject: C++ Exception Handling Date: Thu, 24 Nov 1994 12:15:28 Organization: Capital Area Internet Service info@cais.com 703-448-4470 Lines: 49 Distribution: world Message-ID: <wirt.38.000C4264@cais.cais.com> NNTP-Posting-Host: wwirt.cais.com Keywords: catch try throw X-Newsreader: Trumpet for Windows [Version 1.0 Rev A]