If you have a Simulink® Coder™ or Embedded Coder® license, you can generate C or C++ code from models that include Stateflow® blocks. The following table directs you to code generation information based on your goals.
See the Following Information in the Simulink Coder documentation
Generate C/C++ source code
Code Generation Basics (Simulink Coder)
You cannot generate code only for the Stateflow blocks in a library model. You must first create a link to the library block in your main model and then generate code for the main model.
Generate C/C++ source code and build executable
Build Process (Simulink Coder)
Optimize generated code
Reduce Memory Usage for Boolean and State Configuration Variables (Simulink Coder) and Design Tips for Optimizing Generated Code for Stateflow Objects (Simulink Coder)
Integrate external code
External Code Integration (Simulink Coder)
Include external code only for library charts in a portable, self-contained library for use in multiple models
Integrate External Code for Library Charts (Simulink Coder)