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