什么是一些“好”使用longjmp / setjmp进行C错误处理的方法? [英] What are some "good" ways to use longjmp/setjmp for C error handling?
问题描述
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屋!