![]() |
setjmp, longjmp
is there a portable way of implementing exception handling with setjmp, longjmp?
restoring the state of a program and such really seems like I am asking for undefined behavior. -- nethlek |
Re: setjmp, longjmp
nethlek@tokyo.com (Mantorok Redgormor) wrote:
# is there a portable way of implementing exception handling with setjmp, longjmp? # # restoring the state of a program and such really seems like I am asking # for undefined behavior. It's the only standard way to exit a nest of called functions to a particular point in a calling ancestor. You should not expect to restore local or global variables--if you need that behaviour, store the originals elsewhere and copy back at the setjmp. You should not expect not to restore non-volatile variables--if you need that, declare them volatile. -- Derk Gwen http://derkgwen.250free.com/html/index.html Haven't you ever heard the customer is always right? |
Re: setjmp, longjmp
nethlek@tokyo.com (Mantorok Redgormor) wrote in
news:41ec7ac0.0311120657.75f3081b@posting.google.c om: > is there a portable way of implementing exception handling with > setjmp, longjmp? > > restoring the state of a program and such really seems like I am > asking for undefined behavior. > > -- > nethlek The only state of the program which is not preserved by longjmping are automatic variables IIRC. I wrote a toy exception handling 'thing' a long time ago in here which exploited that fact. You had to specifically preserve the automatic variables you wanted to keep (and you could keep them at stages in the 'try' block), but it was all very much a hack. I'll try and have a dig around and see if I still have it. If not, I might just rewrite it for laughs. Ian Woods |
| All times are GMT. The time now is 02:10 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.