默认/样板代码在Visual Studio 2017中给我错误.E1574.虚幻.但构建成功了

Default/boilerplate code gives me error in Visual Studio 2017. E1574. Unreal. But Build Succeeded

本文关键字:E1574 错误 虚幻 成功 构建 代码 2017 Studio Visual 默认      更新时间:2023-10-16

我正在尝试学习UE4,但目前我被困在做一些非常简单的事情上。我想创建一个突破样式"划桨"作为蓝图。

但是我有一个奇怪的问题,我的代码对我来说看起来不错(我直接从导师视频中复制代码(,但在 Visual Studio 中我收到错误:E1574 静态断言失败,并显示"TAtomic 只能用于普通类型"。我甚至删除了所有代码,只保留了UE4提供的默认代码(当我点击"创建C++类>Actor"时(。构建该错误时仍然存在。

我得到的另一个问题是,对于我在代码中实例化的 StaticMeshComponent,Paddle_BP中的"详细信息"面板是空的。在本教程中,它提供了一个静态网格组件,您可以在其中选择网格,添加物理和其他选项。

这是我的代码:

桨:

#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Paddle.generated.h"
UCLASS()
class SHIT_PONG_CPP_API APaddle : public AActor
{
GENERATED_BODY()
public: 
// Sets default values for this actor's properties
APaddle();
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "ActorMeshComponents")
UStaticMeshComponent* StaticMesh;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public: 
// Called every frame
virtual void Tick(float DeltaTime) override;
};

划桨.cpp

#include "Paddle.h"
// Sets default values
APaddle::APaddle()
{  
// 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;
StaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("CustomStaticMesh"));
}
// Called when the game starts or when spawned
void APaddle::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void APaddle::Tick(float DeltaTime)
{ 
Super::Tick(DeltaTime);
}

我已经阅读了这个线程(静态断言失败,并显示"Windows 标头需要默认打包选项......"( 和 Microsoft (https://learn.microsoft.com/en-us/cpp/build/reference/zp-struct-member-alignment?view=vs-2019( 中有关更改编译器设置的页面。但是说明似乎已经过时了,我根本无法在我的选项中找到"> C/C++> 代码生成的配置属性"。

我认为当你在Visual Studio中构建时会发生此错误。我认为如果您从UE环境中编译,则可以避免此错误。以下是来自虚幻论坛的链接,它提出了相同的解决方案:https://forums.unrealengine.com/development-discussion/c-gameplay-programming/1703131-error-static-assertion-failed-with-tatomic-is-only-usable-with-trivial-types