【问题标题】:What does ::struct mean in this context?::struct 在这种情况下是什么意思?
【发布时间】:2020-04-04 07:45:18
【问题描述】:

我不知道如何搜索这个,因为似乎 google 在我的搜索中忽略了::

我在伪代码中有以下行: (本上下文中的玩家定义为:Player *player

if ( player == ::player )

我的意思是,如果var playerplayer 类型。但这对我来说没有意义,因为编译器应该知道它是什么类型。

那么::player 在这里是什么意思?

【问题讨论】:

  • 对此的任何资源也将不胜感激。

标签: reverse-engineering ida


【解决方案1】:

我没有足够的代表发表评论。所以把它变成了一个完整的答案。

通常:: 运算符用作Scope resolution operator

根据语言,在您的示例中,因为没有前置命名空间,它将引用全局 player

来自链接页面:

class A {
public:
    static int i; // scope of A
};

namespace B {
    int j = 2;
}  // namespace B

int A::i = 4;  // scope operator refers to the integer i declared in the class A
int x = B::j;  // scope operator refers to the integer j declared in the namespace B

在 IDA 的上下文中,它可能是引用全局 player 对象的自己的方式。

所以在你的例子中:

if ( player == ::player )

开发人员明确强制将本地 player 对象/变量与全局命名空间中的 player 对象/变量进行比较。

这里有一个simple online demo 可能会有所帮助。 avar 原始变量可以是更复杂的对象、类或函数,而不是 int。

【讨论】:

  • 嗯,我猜它正在检查调用该函数的播放器是否是本地播放器(本地播放器,而不是在线播放器)。让我失望的是没有类型名称,所以我不确定。
  • 我用一个可能也有帮助的简单在线演示应用更新了答案。
猜你喜欢
  • 2017-03-28
  • 2016-08-26
  • 2014-10-27
  • 2019-10-15
  • 2020-11-03
  • 1970-01-01
  • 1970-01-01
  • 2014-03-27
  • 2016-10-05
相关资源
最近更新 更多