Is there a way to make try-catch statements in mex files?

I know that there is no built-in way to do try-catch statements in C, but has Matlab facilitated any type of try-catch functionality for mex files? I tried to use Longjmp and Setjmp in the way described in http://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html, but I was not successful. Has anyone else figured out a way?

Answers (1)

What about using try-catch by writing the code in C++?

4 Comments

It's a good question (or...answer), but I've already started down the path of porting some of my Matlab application to C. The more I learn about C, the more I think now that C++ would have been a better choice. But is there really no good solution using C???
Fortunately you can put all your C-code into a C++ file, add only some tiny header lines, and use the TRY-CATCH method of C++.
Thanks. There seems to be a problem with your link though.

Sign in to comment.

Categories

Products

Tags

Asked:

on 13 Jun 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!