- Set Data Scope to Imported for all signals using Get/Set.
- This tells Embedded Coder to use your existing code instead of generating new ones.
- In Model Settings → Code Generation → Custom Code, add your header (MyInterface.h) and source (MyInterface.c).
- Make sure the build doesn’t include the auto-generated header from model_ert_rtw/instrumented/.
- Rebuild and check the code generation report — only your header should appear.
Multiple definitions of the same function in generated code
35 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a model where the interfaces are configured as GetSet. Corresponding header file is also added in port configuration. When code is generated, definition for these Get/Set functions are generated in <model>.c file. But there is also a headerfile, with same name as what is configured in the ports generated in instrumented folder inside ert_rtw. This causes multiple definition error when trying to run SIL. How do i avoid the extra header file from being generated. It is already present in my working directory and is added to custome code sttings in model config.
0 Commenti
Risposte (1)
sneha
il 10 Nov 2025 alle 11:10
To avoid having Embedded Coder generate that extra header or duplicate files, you must adjust the storage class / code-generation settings so that the code generator assumes your external file covers the definitions and does not generate its own.
To fix it:
Supporting MathWorks Docs:
https://www.mathworks.com/help/rtw/ug/choose-a-built-in-storage-class-for-controlling-data-representation-in-the-generated-code.html– use this to understand how to control how signals and parameters appear in generated code.
https://www.mathworks.com/help/ecoder/ug/design-custom-storage-classes-and-memory-sections.html– refer here to learn how to define and configure your own storage classes (e.g., Imported, Get/Set).
https://www.mathworks.com/help/ecoder/ug/getset-custom-storage-classes.html– check this for details on using Get/Set to access data through custom getter/setter functions and link external code.
0 Commenti
Vedere anche
Categorie
Scopri di più su Deployment, Integration, and Supported Hardware in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!