How do I prepend a variable declaration with a qualifier in my generated code?

4 vues (au cours des 30 derniers jours)
I am generating C code and I want to add a macro before the variable declarations.
Currently, my generated code looks as follows:
/* Exported block parameters */
float32 variableName = 0.5F; /* Variable: variableName
* Referenced by: '<S5>/Constant1'
*/
I want to add a macro, which is defined in an external header file such that my generated code is as follows:
/* Exported block parameters */macro float32 variableName= 0.5F; /* Variable: variableName
* Referenced by: '<S5>/Constant1'
*/
How do I do this? 
 

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 14 Oct 2022
There are 2 possible ways to prepend the variable declarations in your generated code with a macro, depending on where these parameters are defined in your model.
Parameters Defined in Model Workspace
You can map the parameter to "ConstantMemory" and use additional native type qualifiers to prepend the keywords, by setting "AdditionalNativeTypeQualifier" to be 'macro'.
You can find more about this in the documentation here: https://www.mathworks.com/help/releases/R2021b/autosar/ug/map-model-elements-using-simulink-autosar-mapping-explorer.html#mw_f8f8aab0-d352-46e0-ae2f-9b3e3bdf5da9
Parameters Defined in Base Workspace or SLDD (Simulink Data Dictionary)
You can define a new storage class, assign a memory section with the defined qualifier and map this storage class to the required parameters. You can do this as follows:
  1. Define a new storage class and assign a memory section with the required qualifier: 
  2. Map this storage class to the required parameters: 

Plus de réponses (0)

Catégories

En savoir plus sur Modeling Patterns for C Code Constructs dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by