This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Using EH from C



On Sat, 1 May 2004, david daney wrote:

> 
> I would setjump and set an attfibute(cleanup(function))
> at the catch point, and then longjump from the cleanup function.
>  

Not a bad idea. Like this?

	if (setjmp (&context)) {
		struct pseudo_object X __attribute__((cleanup(pdtor)));
		X.normal_termination = 0;
		X.ctx = &context;
		/* ... */
		X.normal_termination = 1;
	} else {
	}

And pdtor() will either just return or longjmp to ctx depending
on normal_termination.

There's still a minor cost but I guess it's ok.

Thanks,

Stelios



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]