我正在使用 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/