- Define a new storage class and assign a memory section with the required qualifier:

- Map this storage class to the required parameters:

How do I prepend a variable declaration with a qualifier in my generated code?
4 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2022 年 10 月 14 日
回答済み: MathWorks Support Team
2022 年 12 月 15 日
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?
採用された回答
MathWorks Support Team
2022 年 10 月 14 日
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:
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!