c++ - 虚幻引擎 4.16,C++ 包含头文件

标签 c++ header-files unreal-engine4

我正在使用 Unreal Engine 4.16 和 Visual Studio 2017,我正在尝试导入一个类:“PhysicsEngine/PhysicsHandleComponent.h”,但出现了很多错误。

如果我不导入它,一切正常,构建正常,一切正常,所以问题是孤立的。

在头文件 Grabber.h 中,在包含之前,我有这个:

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Grabber.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UGrabber : public UActorComponent
{
    GENERATED_BODY()
    ...

一切正常。

但是只要我包含正确的 header ,就像这样:

#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "PhysicsEngine/PhysicsHandleComponent.h"
#include "Grabber.generated.h"

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UGrabber : public UActorComponent
{
    GENERATED_BODY()
    ...

“UCLASS”(第 10 行)和“class”(第 11 行)带有下划线,不会构建任何内容,并抛出以下错误:

E0077   this declaration has no storage class or type specifier ...\Grabber.h   10
E0065   expected a ';'  ...\Grabber.h   11

为什么不允许我导入这个文件?

编辑:这是正确的文件,拼写正确,是引擎中的一个文件。不是我写的,所以“PhysicsEngine/PhysicsHandleComponent”没有错

最佳答案

我遇到了同样的问题,我发现如果将 generated.h 文件移动到不同的行(通过在其上方按回车键),则会出现错误。尝试使用您已有的 #includes 上方的空白行之一。 (如果需要,您可以移动#pragma once)

关于c++ - 虚幻引擎 4.16,C++ 包含头文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44557155/

相关文章:

c++ - 有没有办法包含 std::filesystem 的转发 header ?

c - 如何在arduino中使用标准c头文件

c++ - 将 AActor 引用传递给嵌套对象

c++ - 搜索已排序的 float 数组

c++ - 如何制作可移植的可执行文件?

c++ - 如何将 C++ 代码公共(public) header 设为内部?

c++ - 是否可以创建动态 AI 路径 "on fly"?

c++ - 如何启用/拱门:AVX for Unreal Engine 4?

C++ 对象的前向声明

java - 为什么父类(super class) B 调用子类 A 的方法?