cexception

Exception handling in pure C


Possible Duplicate:
C : How do you simulate an 'exception' ?

Hi, I know that exception handling is available in C++ but not in C. But I also read that exception handling is provided from OS side, so isnt there any function for C invoking the same behavior from OS as try catch and throw? Thanks.


Solution

  • The C language itself has no support for exception handling. However a means of exception handling for C does exist on a platform + compiler specific basis.

    In Windows for example C programs can use SEH (Structured Exception Handling):

    I've seen arguments in the past that the C function pair setjmp and longjmp is exception handling in C. I consider it closer to the ejection pattern but it's worth investigating