logo       

Re: C++ exceptions: msg#00030

gnu.cegcc.devel

Subject: Re: C++ exceptions

On Thu, Jul 05, 2007 at 02:54:33AM +0100, Pedro Alves wrote:
> #define TRY_EXCEPTION_HANDLER \
> struct eh_data __ehd; \
> int __ret = setjmp(__ehd.env); \
> if (!__ret) { \
> start_ehandling(&__ehd);
>
> #define CATCH_EXCEPTION_HANDLER \
> end_ehandling(&__ehd); \
> } else
>
> Very nice. Hiding the __ehd would be great. If not possible
> then I suggest at least adding ##__LINE__ to it.

I suppose one could do something like:

#define TRY_SEH \
do { \
struct eh_data __ehd; \
int __ret = setjmp(__ehd.env); \
if (!__ret) { \
start_ehandling(&__ehd);

#define CATCH_SEH \
end_ehandling(&__ehd); \
} else {

#define END_SEH \
} \
} while (0);

which would be used with:

TRY_SEH
{
while (wcount--)
*vaddr++ = value;
}
CATCH_SEH
{
Output(C_ERROR "EXCEPTION while writing %08x to address %p",
value, vaddr);
}
END_SEH

This has the advantage that it should work with C code. (I'm pretty
sure you could hide __ehd and not require an END decl with C++, but it
would look ugly and not be significantly better than the previous
implementation.)

Earlier on, I tried to use the same __try/__except syntax that msdn
documents. However, I gave up on it - it was too complicated and not
useful for me. In particular, implementing __finally would be
painful.

-Kevin

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise