How to throw an exception in C?

httpinterpret picture httpinterpret · May 23, 2010 · Viewed 128k times · Source

I typed this into google but only found howtos in C++,

how to do it in C?

Answer

Brian R. Bondy picture Brian R. Bondy · May 23, 2010

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).

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.