“[类]未被宣布”但是克里恩看到了它

时间:2018-06-06 17:58:53

标签: c++ compiler-errors clion undeclared-identifier

我有一个头文件,让我们称之为SomeClass.h,其中通常定义一个类:

class SomeClass {
...
};

SomeClass的实施位于另一个文件中,例如SomeClass.cpp

然后我有另一个头文件,比如AnotherClass.h,它试图使用SomeClass类来定义另一个类,如下所示。

#include <SomeClass.h>

class AnotherClass {
...
protected:
  std::unique_ptr<SomeClass> s;  // (*)
};

当我尝试编译时,我收到以下错误:

error: 'SomeClass' was not declared in this scope

但这是非常令人惊讶的,因为CLion没有检测到这个错误,当我点击上面注释SomeClass的说明中的// (*)时,CLion正确地转到了SomeClass的定义在SomeClass.h

所以问题是:

为什么CLion在编译器没有看到它的时候看到SomeClass

0 个答案:

没有答案
相关问题