我正在尝试同时返回值和对其的引用,但是我不确定如何避免该错误。我唯一的解决方案是返回VariantClear()
,但我想避免使用long Move(int Unit, int Count)
{
long result;
static BYTE parms[] = VTS_PVARIANT VTS_PVARIANT ;
CComVariant vaUnit(Unit);
CComVariant vaCount(Count);
InvokeHelper(0x6d, DISPATCH_METHOD, VT_I4, (void*)&result, parms, &vaUnit, &vaCount);
return result;
}
代码。
long Move(int Unit, int Count)
{
long result;
static BYTE parms[] = VTS_PVARIANT VTS_PVARIANT ;
_variant_t vaUnit(Unit);
_variant_t vaCount(Count);
InvokeHelper(0x6d, DISPATCH_METHOD, VT_I4, (void*)&result, parms, &vaUnit, &vaCount);
return result;
}
错误:
*const
如果我写unsafe
,则会收到错误消息:
struct A<'a> {
r: &'a i32,
}
struct B<'b> {
i: i32,
a: A<'b>,
}
fn test() -> B {
let i = 5;
B { i, a: A { r: &i } }
}
fn main() {
test();
}