将值分配给接口元素,而无需实现实施的实例化

发布于 2025-01-28 08:10:14 字数 314 浏览 3 评论 0原文

我有一个结构(dut),一个元素是接口。

STRUCT myStruct
   element : iInterf;
END_STRUCT

在声明会话中,在将值分配给此元素之前,我必须先实例化(具有相同的实现)。

instance : iInterf_implementation := (some initialization values);
myVar : myStruct := ( element := instance );

可以分配值并实例化接口元素而无需创建其他变量吗?

I have a STRUCT (DUT) which one element is an interface.

STRUCT myStruct
   element : iInterf;
END_STRUCT

In declaration session, I have to instantiate first (with same implementation) before assign value to this element.

instance : iInterf_implementation := (some initialization values);
myVar : myStruct := ( element := instance );

Is possible to assign value and instantiate an interface element without create another variable?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明月松间行 2025-02-04 08:10:14

不是我知道。这是codesys document 代码总是将界面类型声明的变量视为参考。如果接口本质上是指指指针,那么您需要一个变量才能引用/点。

Not that I know of. Here's a quote from the CODESYS documentation: CODESYS always treats variables declared with the type of an interface as references. If an interface is essentially a reference, which is essentially a pointer, then you need a variable for the interface to refer/point at.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文