- Create "foo.h" in your project
- Navigate to Configuration Parameters > Code Generation > Custom Code
- Configure "Include headers" and "Include directories" to import your "foo.h" header file
- Modify "foo.h" to mark your getter and setter functions as "extern" similar to the example below
Can I automatically generate implementations for getters and setters when using the GetSet storage class?
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MathWorks Support Team
am 26 Jun. 2024
Bearbeitet: MathWorks Support Team
am 15 Jul. 2024
I am using Simulink R2023b with Embedded Coder. My model has inports and outports whose storage classes are set to "GetSet". Additionally the header file ("foo.h") to find the getter and setter functions have been configured. When I generate code, I get the following error:
fatal error: foo.h: No such file or directory
I also see this error when I run a SIL/PIL simulation. How can I work around this error?
Akzeptierte Antwort
MathWorks Support Team
am 15 Jul. 2024
Currently Embedded Coder does not support automatically generating getter and setter implementations for code generation. The GetSet storage class helps with integrating generated code with legacy applications, so you will need to supply your own getter and setter implementations in "foo.h". Because getter and setter implementations can differ across applications by holding application specific logic such as logging and maintaining invariants, Embedded Coder cannot generate these implementations. However, our development team is aware that it can be useful to generate generic getters and setters. They will consider resolving this limitation in a future release.
For SIL/PIL simulations, Embedded Coder will generate generic implementations for getter and setter functions. The "Interfaces That Produce Additional Generated Code" section in the article below documents this feature.
To workaround this issue, you can import a skeleton header file that defines your getter and setter functions as "extern". Doing so will tell the compiler to find the implementations in the SIL/PIL manager's generated implementation. Please try doing the following steps.
#ifndef FOO_H
#define FOO_H
extern double get_Inport();
extern set_Outport(double);
#endif
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Deployment, Integration, and Supported Hardware finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!