How to set the scope of C + + code generated by datastore module to public?

1 view (last 30 days)
By default, the scope of the variables generated by the datastore module is private. how can I modify the model to make the scope of the generated variables to public?

Answers (1)

Harshit Desai
Harshit Desai on 17 Mar 2021
Edited: Harshit Desai on 18 Mar 2021
I understand that you are trying to make the data store module scope public in the generated code and I am assuming you are using R2020b or before.
Until MATLAB R2020b, the code mapping for Target language C++ was not supported.
But from MATLAB 2021a, MathWorks product Embedded Coder is supporting Code mapping for C++. So if you like you can upgrade to R2021a. But if upgrading isnt an option, then this limitation would exist.
But if you do upgrade then :
This tool lets you customize the generated code by changing the data visibility and member access functions.
You can find more Information on this MathWorks documentation page --> https://www.mathworks.com/help///ecoder/ref/codemappingsceditor.html
To Answer your question.
You can change the scope of the variables by opening the code mappings pane by
  1. clicking on 3 dots on the bottom right on the simulink canvas or
  2. From the tool strip click on Code Interface --> code mappings
Then you can select in the Data Tab --> Signals, state and internal data and change the visibility to public.

Community Treasure Hunt

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

Start Hunting!