This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
TRY_CATCH()
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb at sources dot redhat dot com
- Date: Wed, 12 Jan 2005 19:08:00 -0500
- Subject: TRY_CATCH()
Hello,
The exceptions rewrite opens up a key possibility. It's now possible to
define a macro such that:
struct args
{
...
};
do_func (void *data)
{
struct args *args = data;
... do stuff ...;
}
func (...)
{
struct args args;
args... = ...;
struct exception e = catch_exception (..., func, &args, ...)
switch (e.reason)
...
}
can be replaced with the more compact:
func (...)
{
volatile struct exception e;
TRY_CATCH (e)
{
... do stuff ...;
}
switch (e.reason)
...
}
Yes I know macros a bad, m'kay. However, this offers a simple way to
rewrite the code using something more like a real programming languages
try/catch.
Andrew
PS: I recall this being proposed years ago, but the mechanism proposed
at the time had a more cumbersom syntax, from memory something like:
TRY_BEGIN
... do stuff ...
TRY_END;
comments?
Andrew