C3646和C4430是否由于头文件层次结构? [英] C3646 and C4430 due to header file hierarchy?

查看:220
本文介绍了C3646和C4430是否由于头文件层次结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了两个编译错误:C3646和C4430。让我告诉你:

I'm faced with two compilation errors: C3646 and C4430. Let me show you:

我指的是这个头文件:

Timer.h

class Timer {
}

这段源代码工作正常(在头文件中):

This piece of source code is working fine (in a header file):

#include "Timer.h"
class Something{
    Timer timer_;

这段源代码不起作用(在另一个头文件中):

This piece of source code is not working (in another header file):

class Something_else : public Singleton<Something_else> {
    friend Singleton<Something_else>;
    Timer getDebuggerTimer;

我得到的编译错误是上述错误:

The compilation errors I get are the mentioned ones:


C3646'getDebuggerTime':未知的覆盖说明符

C3646 'getDebuggerTime': unknown override specifier

C4430缺少说明符-假定为整数。

C4430 missing specifier - int assumed.

我有试图包含提到的头文件 Timer.h ,但这使情况变得更糟(我相信此文件已经通过其他包含条目包含在内)。

I have tried to include the mentioned header file Timer.h but this is making things even worse (I believe this file is already included via the other include entries).

为什么编译器期望覆盖说明符? (据我所知,不需要它们,我只是在向一个类添加属性?)

Why is the compiler expecting override specifiers? (As far as I know there's no need for them, I'm just adding a property to a class?)

在其他使用该属性的地方,该值会填入相应类的构造函数(也在头文件中)。

On the other places where it's used, the value is filled in in the constructor of the corresponding class (also in the header file). Does this have any impact on this issue?

供您参考: Singleton 用于实现相应的设计模式。

For your information: the Singleton is used for implementing the corresponding design pattern.

一个额外的说明:问题(乍一看)似乎与名称空间无关。

An extra remark: the issue (at first sight) seems not to be related to namespaces.

推荐答案

与此同时,我已经理解了问题的根本原因:

Meanwhile I've understood the root cause of the problem:

如上所述,在源代码(头文件)中写着:

As mentioned, in the source code (header file), there's written:

Timer getDebuggerTimer;

Visual Studio的编辑器接受这一行源代码( Timer ),然后在按 F12 的同时进入Timer.h文件,其中定义了上述类。

Visual Studio's editor accepts this line of source code (no red waves under the word Timer), and while pressing F12 I get into the file Timer.h, where the mentioned class is defined.

但是,编译器似乎不同意:编译器在头文件 Timer中找不到 Timer 类的定义。 h,但他没有说标识符不理解,而是给出了奇怪的编译消息。

However, the compiler does not seem to agree: the compiler does not find the definition of the Timer class in the header file "Timer.h", but instead of saying identifier not understood, he gives that strange compilation message.

我如何找到

我已将 Timer getDebuggerTimer 替换为 BlablaTimer getDebuggerTimer 。这样做时,编辑器显示了提示标识符 BlablaTimer未定义,但编译器继续给出相同的编译器错误C3646和C4430。

I've replaced Timer getDebuggerTimer by BlablaTimer getDebuggerTimer. When doing that the editor showed the hint identifier "BlablaTimer" is undefined but the compiler kept on giving the same compiler errors C3646 and C4430.

我现在正在进一步挖掘以便知道如何解决此问题,但是我确实认为不应将简单的未定义标识符显示为编译器有些奇怪的未知的覆盖说明符

I'm now digging further in order to know how I can solve this issue, but I do believe that a simple undefined identifier should not be shown as some weird unknown override specifier by the compiler.

这篇关于C3646和C4430是否由于头文件层次结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆