matlab coder: It's time to generate a modern C++ API
Show older comments
The matlab coder product is very widely used in industry, and since the R2011 version, the generation is still mainly oriented towards the C API interface (C++ is actually a layer of wrapper for C) to common one-/two-dimensional arrays, colum-major, involving low-level operations such as memory management allocation and release. As history progressed, we moved more towards the modern form of the C++ API (C++11), with safer use of smart pointers, threaded support, and better security and convenience similar to the mex C++ API introduced by MATLAB R2017b. Using the older C API can often cause memory management problems and be difficult to debug.
Once we have implemented our algorithms quickly in matlab, we often have to iterate matlab syntax often on generating C/C++ code, and array bounds often have to be considered, as it is particularly important in C to consider is allocating memory on the stack and heap. The array size in the current generated C code can easily be very large, e.g. myarray[largeNumber] in image processing toolbox, and then a Segmentation Fault error will occur. This adds a lot of annoying overhead and requires a lot of effort to keep changing the code. It would be much better if the generated C++ code was in the new C++11, such as std::vector, which does not take into account the array size limit and allows the developer to focus on the algorithm itself.
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Coder in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!