如何在 C 中抛出异常? [英] How can I throw an exception in C?

查看:43
本文介绍了如何在 C 中抛出异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Google 中输入了这个,但我只在 C++ 中找到了操作方法.

I typed this into Google, but I only found how-tos in C++.

我如何在 C 中做到这一点?

How can I do it in C?

推荐答案

C 中没有异常.在 C 中,错误通过函数的返回值、进程的退出值、给进程的信号来通知(程序错误信号 (GNU libc)) 或CPU 硬件中断(或 CPU 的其他通知错误,如果有)(处理器如何处理被零除的情况).

There are no exceptions in C. In C the errors are notified by the returned value of the function, the exit value of the process, signals to the process (Program Error Signals (GNU libc)) or the CPU hardware interruption (or other notification error form the CPU if there is)(How processor handles the case of division by zero).

异常是在 C++ 和其他语言中定义的.C++ 中的异常处理在 C++ 标准S.15 异常处理"中有规定,C 标准中没有等效的部分.

Exceptions are defined in C++ and other languages though. Exception handling in C++ is specified in the C++ standard "S.15 Exception handling", there is no equivalent section in the C standard.

这篇关于如何在 C 中抛出异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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