问题描述
在 unqlite 库中,我找到了以下代码:
In unqlite c library I found following code:
pObj = jx9VmReserveMemObj(&(*pVm),&nIdx);
其中pVm
是:
typedef struct jx9_vm jx9_vm;
jx9_vm *pVm
和被调用的函数声明为:
and function called is declared as:
jx9_value * jx9VmReserveMemObj(jx9_vm *, sxu32 *);
构造&(*pVm)
在调用中使用的是什么,而不仅仅是pVm
? &(*pVm)
等同于pVm
吗?
What for construct &(*pVm)
is used in call instead of just pVm
? Is &(*pVm)
equivalent to pVm
?
推荐答案
引用C11
,第6.5.3.2章,地址和间接操作符
Quoting C11
, chapter §6.5.3.2, Address and indirection operators
因此,是,它们是等效的.
但是,可以使用此构造根据指针类型检查参数的类型.从一元*
运算符的属性中,
This construct can be used, however, to check the type of the argument against a pointer type. From the property of unary *
operator,
因此,构造&(*pVm)
- 如果
- 会很好. 如果
- 将生成编译器错误.
pvm
是指针或数组名称,则pvm
是非指针类型变量,则- will be fine, if
pvm
is a pointer or array name. - will generate compiler error, if
pvm
is a non-pointer type variable.
有关代码示例,请参见 Alter Mann的其他答案.
See the other answer by Alter Mann for code-wise example.
另一个区别(通常是 )是,pVm
可以被分配(可以用作赋值运算符的LHS),但是&(*pVm)
不能.
One more difference (in general) is, pVm
can be assigned (can be used as LHS of the assignment operator), but &(*pVm)
cannot.
这篇关于取消引用的指针构造的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!