什么是一些“好”使用longjmp / setjmp进行C错误处理的方法? [英] What are some "good" ways to use longjmp/setjmp for C error handling?

查看:182
本文介绍了什么是一些“好”使用longjmp / setjmp进行C错误处理的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须为一个项目使用C,我正在考虑使用 longjmp / setjmp 进行错误处理,因为我认为在一个中心处理错误会更容易地方比返回码。如果有这样的一些潜在客户,我将不胜感激。



如果发生任何此类错误,我特别关心资源清理是否正确完成。



另外如何处理导致使用多线程程序的错误?



更好的是有一些已经存在错误/异常处理的C库?

解决方案

看看这个例子/教程:

http://www.di.unipi.it/~nids /docs/longjump_try_trow_catch.html


I have to use C for one project and I am thinking of using longjmp/setjmp for error handling as I think it will be much easier to handle error in one central place than return codes. I would appreciate if there are some leads on how to do this.

I am particularly concerned with resource cleanup being correctly done if any such error occurs.

Also how do I handle errors that result in multi-threaded programs using them?

Even better, is there some C library that already exists for error/exception handling?

解决方案

Have a look at this example/tutorial:
http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html

这篇关于什么是一些“好”使用longjmp / setjmp进行C错误处理的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆