虚幻引擎4.16,C++包含头文件
Unreal Engine 4.16, C++ Include header files
我正在使用虚幻引擎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()
...
一切都正常。
但是一旦我包含正确的标题,就像这样:
#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"没有错
我遇到了同样的问题,我发现如果您将生成的.h文件移动到另一行(通过在其上方按回车键(,则会出现错误。尝试使用现有 #includes 上方的空白行之一。(如果需要,您可以移动 #pragma 一次(
我在虚幻引擎16.1和Visual Studio 2017的不同标题上遇到了相同的错误。虽然我不完全确定是什么原因造成的,但解决方案是简单地将导入移动到.cpp文件中,而不是头 (.h( 文件中。
我相信这与虚幻生成的预编译标头有关,一旦我们尝试包含不同的标头,Visual Studio 可能无法再正确看到它们。
相关文章:
- 使用mongocxx驱动程序时包含头文件问题
- 如何为包含头文件的目标编写生成文件?
- 如何在 CMakeLists.txt Qt Creator 中包含头文件?
- 当包含头文件的文件不在根项目文件夹中时,如何包含它
- 在生成文件先决条件中包含头文件的原因
- My Project的属性配置正确,但Visual Studio仍然无法打开包含头文件
- 在 PostgreSQL C 扩展中包含头文件
- 是否可以在C++中以间接方式包含头文件
- 是否需要包含头文件?
- 我收到未声明的标识符错误,但我已包含头文件?
- 为什么我们需要构建一个提升库,仅仅包含头文件还不够吗,因为提升是模板
- C++:当顺序真正重要时,如何保证在项目中包含头文件的顺序
- 如何在C++中包含头文件时错误地重载
- 我在C++中无效使用不完整的类型类错误,如何正确包含头文件?
- 虚幻引擎4.16,C++包含头文件
- C++多次包含头文件
- 令牌之前的预期类名 '{' - 包含头文件和 CPP 文件
- 在atom中生成c++包含头保护
- 在.cpp中包含头文件会导致令人讨厌的错误
- 如何列出用于在Qt项目中包含头文件的所有路径