Why does Embedded Coder for C++ have less options for Storage Class for code interface compared to C?

2 次查看(过去 30 天)
I'm a beginner when it comes to Embedded Coder, and I'm trying to understand how to control the interface and storage class of parameters for my model. I noticed that when the model is set to generate C code, there are lots of options in the Code Mappings pane for setting the Storage Class of parameters such as Simulink.Parameters defined in the model workspace. But when I set the model to generate C++ code, the Code Mappings pane does not show Storage Class or many other options shown in the C code version. Is there a reason why those options are not available for C++ code? If I have a Simulink.Parameter parameter defined in the model workspace, but I would like to make it tunable so that it is not inlined as a literal in the C++ code, how do I do that without changing the model configuration parameter default from Inlined to Tunable, which will affect all parameters. I discovered one way to do it is by defining the Simulink.Parameter in the base workspace instead of the model workspace and setting the Storage Class to ImportedExtern, for example. But if you then import that paramter into the Model Workspace, it says that it ignores the storage class and uses Auto instead. What's the reason for this?

回答(1 个)

Abhinav Aravindan
Abhinav Aravindan 2024-11-13
Hi Michael,
  1. Enabling Storage classes forSimulink.Parameter” in Model workspace for C++ generated code does not seem to be supported currently due to which Storage Class Options are not shown for C++ code.
  2. To use tunable Simulink.Parameter without changing the Model Configuration Parameters from “Inlined” to “Tunable”, you may refer to the following link: https://www.mathworks.com/matlabcentral/answers/1992278
  3. To store “Simulink.Parameter in the Model workspace, the storage class must be set to Auto as per the documentation below, due to which you may be noticing the behaviour. If you specify a storage class other than “Auto”, you must store it in the Base workspace or a “Data dictionary” to ensure the objects are unique within the global Simulink context and accessible to all models.

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

产品


版本

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by