【发布时间】:2012-03-15 11:57:11
【问题描述】:
如果我将void *vptr 传递给以other_type *ptr 作为参数的函数,vptr 会自动转换为other_type * 吗?这是代码,
typedef struct A {
//...
}A;
void bar(A *a)
{
//do something with a
}
int main()
{
A a = {..};
void *vp = &a;
bar(vp); //will vp be converted to A*?
}
我的代码安全还是正确?
【问题讨论】:
-
你得到什么结果?错误,警告?
标签: c void-pointers