MIDL(常量)参考 [英] MIDL (Constant) References
问题描述
MIDL方法声明中没有常量引用吗??
Are there no constant references in MIDL method declarations????
例如
[id(1), helpstring("My Method")]
HRESULT MyMethod(
[in] IID & const rclsid
);
为
HRESULT MyMethod(
IID const &rclsid
);
推荐答案
MIDL并不真正支持参考参数,它仅支持"in"和"out"参数.因此,如果您确实传递了引用,则它只是指向该值的指针的语法糖(问题是可观察性-如果您在我们的方法签名中具有回调函数或接口,则可以从回调中观察到对引用的更改,但是在函数返回之前,对[out]参数的更改是不可见的.
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.
此外,& const"和"const&"之间的区别迷路了.如果您查看REFGUID的定义,您会发现它们仅对C ++代码使用一种形式的"const":
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:
#ifdef __midl_proxy
#define __MIDL_CONST
#else
#define __MIDL_CONST const
#endif
#ifndef _REFGUID_DEFINED
#define _REFGUID_DEFINED
#ifdef __cplusplus
#define REFGUID const GUID &
#else
#define REFGUID const GUID * __MIDL_CONST
#endif
#endif
这篇关于MIDL(常量)参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!