(*new) 是做什么的?
我正在尝试解决我的应用程序在使用 activemq-cpp-3.4.0 库时遇到的问题,并且已经到了我正在逐行跟踪以查看问题所在的地步。应用问题本身与这个问题无关;我遇到了一些我不明白的代码,我希望有人能解释发生了什么。
追踪下去,我发现了以下代码(注意:这在技术上是在 apr 库中):
alloc_socket(new, cont);
/* For right now, we are not using socket groups. We may later.
* No flags to use when creating a socket, so use 0 for that parameter as well.
*/
(*new)->socketdes = socket(family, type, protocol);
if ((*new)->socketdes == INVALID_SOCKET) {
return apr_get_netos_error();
}
我对 alloc_socket(new, cont)
感到很困惑,但具体来说我对发生的事情感兴趣与(*新)通话。这是否会分配另一个 this
实例?如果是这样,再次使用 (*new)
检查存储的 socketdes
值是否是一个谬误,因为这会创建另一个单独的实例?或者我完全偏离了轨道?
I'm trying to troubleshoot an issue my application is having with the activemq-cpp-3.4.0 library, and gotten to the point that I'm tracing line by line to see where it's going wrong. The application problem itself is tangential to this question; I came across some code that I don't understand, and I'm hoping someone can explain what's going on.
Tracing down, I find the following code (note: this is technically within the apr library):
alloc_socket(new, cont);
/* For right now, we are not using socket groups. We may later.
* No flags to use when creating a socket, so use 0 for that parameter as well.
*/
(*new)->socketdes = socket(family, type, protocol);
if ((*new)->socketdes == INVALID_SOCKET) {
return apr_get_netos_error();
}
I'm confused enough by the alloc_socket(new, cont)
, but specifically I am interested in what's going on with the (*new) calls. Does this allocate another instance of this
? If so, is it a fallacy to check the stored socketdes
value by using (*new)
again, as that would create another, separate, instance? Or am I just completely off track?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是C代码。在 C 语言中,
new
是一个标识符,而不是关键字。This is C code. In C,
new
is an identifier, not a keyword.