I have a model containing an Embedded MATLAB Function block that uses an intermediate structure variable, whose type is defined in an external header file called "mytypes.h". The eml.cstructname directive is used with the 'extern' parameter to achieve this, and the custom header file is included in the 'Simulation Target->Custom Code' and 'Real-Time Workshop->Custom Code' panes of the Configuration Parameters window.
When I build this subsystem as a reusable function with a user-specified name, the code generated from it does not compile. The compiler errors occur because the externally defined C structure is not recognized, due to the fact that Real-Time Workshop does not include my custom header file in the generated code before it is used.
In order to avoid the compiler error, Real-Time Workshop Embedded Coder must include my custom header file in <model>_types.h and not <model>.h.
Best Answer