MATLAB: Can I use the C++ Standard Template Library (STL) in the custom code for a Simulink Real-Time model

compileerrorreal timeSimulink Real-Timestlxpc

I get compilation errors when attempting to build a model that contains custom code for a Simulink Real-Time target. Is use the C++ Standard Template Library (STL) in my custom code and wrap it in an S-Function. Can I use the STL with Simulink Real-Time models?

Best Answer

The C++ Standard Template Library does not guarantee real-time code. Therefore, compilation errors will result when a model intended for deployment to a Real-Time target is built.
This is discussed in detail in the following MATLAB Answers post: