How to reuse header files for multiple code generation processes?

7 ビュー (過去 30 日間)
I am trying to generate C code for an ECU (engine control unit) using Simulink. There are two separate code generation processes in my workflow, one to generate the deployed code and another to generate the ECU code.
I need to use shared variables in both code-generation processes which should be defined in a header file. To generate the header file, I use the "Exported Global" storage class, but this approach generates two header files from the two code-generation processes.
Is there a way to generate only one header file containing the variable definitions for both code-generation processes?

採用された回答

MathWorks Support Team
MathWorks Support Team 2023 年 5 月 19 日
It is possible to generate a single header file for the two code generation processes by using the "Exported Global" storage class and the "ExportToFile" storage class. The following are the steps:
1.) For the first code generation process ("Process1"), generate the code as before with the "Exported Global" storage class for the shared variables. The following is an example of the output of this code generation process:
2.) In the second code generation process ("Process2"), define the shared variables with the "ExportToFile" storage class, this will prompt for the input of the "HeaderFile" and "DefinitionFile" in the code generation options. Please enter the header file and the C file generated from the first process as shown below:
This setting reuses the header file from "Process1" in the code generation for "Process2". Therefore, only the header file from "Process1" is generated.
More information about the "ExportToFile" storage class can be found in the link below:
https://www.mathworks.com/help/releases/R2023a/ecoder/ug/choose-a-built-in-storage-class-for-controlling-data-representation-in-the-generated-code.html#mw_c20cbc69-9433-4e68-935d-40becbc82d4d

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDeployment, Integration, and Supported Hardware についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by