Can I automatically generate implementations for getters and setters when using the GetSet storage class?

18 次查看(过去 30 天)
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?

采纳的回答

MathWorks Support Team
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.
  • 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
#ifndef FOO_H
#define FOO_H
extern double get_Inport();
extern set_Outport(double);
#endif

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

标签

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by