0

I have a bunch of C functions in my Objective-C project iOS app, that can potentially crash. I want to be able to handle those crashed. At first, I thought to use @try-catch mechanism, but as far as I understand, all exceptions inside this block must be thrown to be handled. Is it true? How can I solve my problem?

For example, this is a call of a C function in Objective-C code. Potentially this function can crush.

err = mailimap_list(session, "", "*", &allList);
3
  • "How can I solve my problem?" Make sure your C code does not crash. Commented Feb 6, 2013 at 13:58
  • The documentation suggests that you need to check the returned error code--in your code, err--namely, check that it is not MAILIMAP_NO_ERROR. Is this what you're referring to? Commented Feb 6, 2013 at 13:59
  • No, this function sometimes doesn't even return err. It just crashes inside. Commented Feb 6, 2013 at 14:10

2 Answers 2

2

Long story short: you can't.

Long explanation: C doesn't have "exceptions". If C code crashes, that's something fatal concerning the life of the process. For example, a detected segmentation fault will make the OS terminate your process. These are not nice Obejctive-C-style exceptions which can be handled.

Sign up to request clarification or add additional context in comments.

Comments

1

Is there such thing as 'C exceptions' ? If they don't exist, you don't have to handle them : problem solved !

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.