将值分配给接口元素,而无需实现实施的实例化
我有一个结构(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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是我知道。这是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.