分配变量时获取变量的地址合法吗?
我想做这样的事情:
void* ptr = some_function(&ptr);
这在 C 中合法吗?
I want to do something like this:
void* ptr = some_function(&ptr);
Is this legal in C?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,这是完全合法的。请注意,您的 some_function 将需要具有此签名:
Yes, it's totally legal. Beware that your some_function will need to have this signature :
这是明确定义的。没有明确定义的是取消引用
some_function
中的指针。That is well-defined. What would not be well-defined would be to dereference the pointer in
some_function
.是的。这是正确的。
您有具体问题吗?
Yes. It is correct.
Do you have a specific problem?