Unreal Engine 4.19 C++ 未声明的标识符错误,但它的代码已声明
Unreal Engine 4.19 C++ Undeclared Identifier error, but it code IS declared
这也发布到 Unreal 的 AnswerHub,但他们的响应速度很慢,我想知道这是 Unreal Engine 错误还是 Visual Studio 2013/C++ 通用错误。我想如果这是一个一般性错误,那么 Whosebug 会指出来。
基本上无缘无故 Visual Studio 开始在正确检测代码时遇到问题,说空函数中有未知符号,然后它开始说已经工作的代码中有未声明的标识符,或者“->”不是'已知等。另一个文件给我这些错误 http://i.imgur.com/AVrbdTS.png?1 下面是我用来显示我的问题的代码。再次尝试时,它说无法打开 ToggleForBP.generated.h
这是 Visual Studio 2013 还是 Unreal Engine 的错误?
我的.h
// 在项目设置的描述页面中填写您的版权声明。
#pragma once
#include "GameFramework/Actor.h"
#include "ToggleForBP.generated.h"
UCLASS()
class PLAYGROUND_API AToggleForBP : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AToggleForBP();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick(float DeltaSeconds) override;
//Toggles between on and off
void SwitchOnOff();
bool UniqueValueBlah;
};
我的.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Playground.h"
#include "ToggleForBP.h"
// Sets default values
AToggleForBP::AToggleForBP()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
void SwitchOnOff()
{
UniqueValueBlah = true;
}
// Called when the game starts or when spawned
void AToggleForBP::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AToggleForBP::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
我从上面的代码得到的错误:
Error 2 error : Failed to produce item: D:\Unreal Projects\Playground\Binaries\Win64\UE4Editor-Playground-3827.dll D:\Unreal Projects\Playground\Intermediate\ProjectFiles\ERROR Playground
Error 1 error C2065: 'UniqueValueBlah' : undeclared identifier D:\Unreal Projects\Playground\Source\Playground\ToggleForBP.cpp 18 1 Playground
Error 3 error MSB3073: The command ""D:\Programs\Epic Games\Epic Games.9\Engine\Build\BatchFiles\Build.bat" PlaygroundEditor Win64 Development "D:\Unreal Projects\Playground\Playground.uproject" -rocket -waitmutex" exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 38 5 Playground
4 IntelliSense: identifier "UniqueValueBlah" is undefined d:\Unreal Projects\Playground\Source\Playground\ToggleForBP.cpp 18 2 Playground
将您的函数签名更改为:
void AToggleForBP::SwitchOnOff()
{
UniqueValueBlah = true;
}
没有把它做成成员函数,编译器认为它是一个全局函数。
这也发布到 Unreal 的 AnswerHub,但他们的响应速度很慢,我想知道这是 Unreal Engine 错误还是 Visual Studio 2013/C++ 通用错误。我想如果这是一个一般性错误,那么 Whosebug 会指出来。
基本上无缘无故 Visual Studio 开始在正确检测代码时遇到问题,说空函数中有未知符号,然后它开始说已经工作的代码中有未声明的标识符,或者“->”不是'已知等。另一个文件给我这些错误 http://i.imgur.com/AVrbdTS.png?1 下面是我用来显示我的问题的代码。再次尝试时,它说无法打开 ToggleForBP.generated.h
这是 Visual Studio 2013 还是 Unreal Engine 的错误?
我的.h // 在项目设置的描述页面中填写您的版权声明。
#pragma once
#include "GameFramework/Actor.h"
#include "ToggleForBP.generated.h"
UCLASS()
class PLAYGROUND_API AToggleForBP : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AToggleForBP();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick(float DeltaSeconds) override;
//Toggles between on and off
void SwitchOnOff();
bool UniqueValueBlah;
};
我的.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "Playground.h"
#include "ToggleForBP.h"
// Sets default values
AToggleForBP::AToggleForBP()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
void SwitchOnOff()
{
UniqueValueBlah = true;
}
// Called when the game starts or when spawned
void AToggleForBP::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AToggleForBP::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
}
我从上面的代码得到的错误:
Error 2 error : Failed to produce item: D:\Unreal Projects\Playground\Binaries\Win64\UE4Editor-Playground-3827.dll D:\Unreal Projects\Playground\Intermediate\ProjectFiles\ERROR Playground
Error 1 error C2065: 'UniqueValueBlah' : undeclared identifier D:\Unreal Projects\Playground\Source\Playground\ToggleForBP.cpp 18 1 Playground
Error 3 error MSB3073: The command ""D:\Programs\Epic Games\Epic Games.9\Engine\Build\BatchFiles\Build.bat" PlaygroundEditor Win64 Development "D:\Unreal Projects\Playground\Playground.uproject" -rocket -waitmutex" exited with code -1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets 38 5 Playground
4 IntelliSense: identifier "UniqueValueBlah" is undefined d:\Unreal Projects\Playground\Source\Playground\ToggleForBP.cpp 18 2 Playground
将您的函数签名更改为:
void AToggleForBP::SwitchOnOff()
{
UniqueValueBlah = true;
}
没有把它做成成员函数,编译器认为它是一个全局函数。