MIDL(常量)参考
MIDL 方法声明中没有常量引用吗???
例如。
[id(1), helpstring("My Method")]
HRESULT MyMethod(
[in] IID & const rclsid
);
为了
HRESULT MyMethod(
IID const &rclsid
);
Are there no constant references in MIDL method declarations????
eg.
[id(1), helpstring("My Method")]
HRESULT MyMethod(
[in] IID & const rclsid
);
for
HRESULT MyMethod(
IID const &rclsid
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MIDL 并不真正支持引用参数,它只支持“in”和“out”参数。因此,如果您确实传递了一个引用,它只是指向该值的指针的语法糖(问题是可观察性 - 如果您在我们的方法签名中有一个回调函数或接口,则可以从回调中观察到对引用的更改,但是在函数返回之前,对 [out] 参数的更改是不可见的。
此外,如果您查看 REFGUID 的定义,您会发现“& const”和“const &”之间的区别。他们只对 C++ 代码使用一种形式的“const”:
MIDL doesn't really support reference parameters, it only supports "in" and "out" parameters. So if you DO pass in a reference, it's just syntactic sugar for a pointer to the value (the issue is observability - if you have a callback function or interface in our method signature, changes to a reference would be observable from the callback, but changes to an [out] parameter aren't visible until the function returns.
In addition, the difference between "& const" and "const &" are lost. If you look at the definition of REFGUID, you'll see that they only use one form of "const" for C++ code: