Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
虚幻引擎4.16,C++包含头文件_C++_Header Files_Unreal Engine4 - Fatal编程技术网

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

虚幻引擎4.16,C++包含头文件,c++,header-files,unreal-engine4,C++,Header Files,Unreal Engine4,我正在使用Unreal Engine 4.16和Visual Studio 2017,我正在尝试导入一个类:physicEngine/physicHandleComponent.h,我得到了很多错误 如果我不导入它,那么一切都可以正常工作,构建正常,一切都可以,所以问题是孤立的 在头文件Grabber.h中,在包含之前,我有以下内容: #pragma once #include "CoreMinimal.h" #include "Components/ActorComponent.h" #in

我正在使用Unreal Engine 4.16和Visual Studio 2017,我正在尝试导入一个类:physicEngine/physicHandleComponent.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()
    ...
一切正常

但只要我包含正确的标题,就像这样:

#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()
    ...
类第10行和类第11行加下划线,不会生成任何内容,并抛出以下错误:

E0077   this declaration has no storage class or type specifier ...\Grabber.h   10
E0065   expected a ';'  ...\Grabber.h   11
为什么不让我导入这个文件


编辑:这是正确的文件,拼写正确,并且是引擎中的文件。我没有写它,因此PhysicsEngine/PhysicsHandleComponent没有任何问题

我在使用Unreal Engine 16.1和Visual Studio 2017时遇到了相同的错误。虽然我不完全确定是什么原因导致了这种情况,但一种解决方案是简单地将导入移到.cpp文件中,而不是移到header.h文件中


我相信这与预编译的头文件unreal generates有关,当我们尝试包含不同的头文件时,visual studio可能无法正确地看到它们。

我也遇到了同样的问题,我发现如果按上面的enter键将生成的.h文件移到另一行,则会出现错误。尝试使用上面已经包含的一个空白行。如果需要,可以移动pragma一次

此链接有帮助吗,尤其是最后一篇文章?