Visual studio error and unreal engine error

************************ code PositionReport.cpp: ************************

// Fill out your copyright notice in the Description page of Project Settings.

#include “PositionReport.h”
#include “GameFramework/Actor.h”

// Sets default values for this component’s properties
UPositionReport::UPositionReport()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don’t need them.
PrimaryComponentTick.bCanEverTick = true;

// ...

}

// Called when the game starts
void UPositionReport::BeginPlay()
{
Super::BeginPlay();

// ...
//Fstring ObjectName = GetOwner() -> GetName();
FString ObjectName = GetOwner()->GetFName().ToString();
UE_LOG(LogTemp, Warning, TEXT("Position Reporting for Duty of %s"), *ObjectName);


FString ObjectPos = GetOwner()->GetActorLocation().ToString(); 
UE_LOG(LogTemp, Warning, TEXT("%s is at %s"), *ObjectName, *ObjectPos);

}

// Called every frame
void UPositionReport::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

// ...

}

************************ code PositionReport.h: ************************
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include “CoreMinimal.h”
#include “Components/ActorComponent.h”
#include “PositionReport.generated.h”
#include “GameFramework/Actor.h”

		   s

UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDINGESCAPE_API UPositionReport : public UActorComponent
{
GENERATED_BODY()

public:
// Sets default values for this component’s properties
UPositionReport();

protected:
// Called when the game starts
virtual void BeginPlay() override;

public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

};

************************ Visual studio 2019 ************************
1>------ Build started: Project: BuildingEscape, Configuration: Development_Editor x64 ------
1>Creating makefile for BuildingEscapeEditor (no existing makefile)
1>Parsing headers for BuildingEscapeEditor
1> Running UnrealHeaderTool “C:\Users\GL63\Documents\Unreal Projects\BuildingEscape\BuildingEscape.uproject” “C:\Users\GL63\Documents\Unreal Projects\BuildingEscape\Intermediate\Build\Win64\BuildingEscapeEditor\Development\BuildingEscapeEditor.uhtmanifest” -LogCmds=“loginit warning, logexit warning, logdatabase error” -Unattended -WarningsAsErrors -abslog=“C:\Users\GL63\AppData\Local\UnrealBuildTool\Log_UHT.txt” -installed
1>C:/Users/GL63/Documents/Unreal Projects/BuildingEscape/Source/BuildingEscape/PositionReport.h(8): error : #include found after .generated.h file - the .generated.h file should always be the last #include in a header
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(46,5): error MSB3073: The command “chcp 65001 >NUL && “C:\Program Files\Epic Games\UE_4.25\Engine\Build\BatchFiles\Build.bat” BuildingEscapeEditor Win64 Development -Project=“C:\Users\GL63\Documents\Unreal Projects\BuildingEscape\BuildingEscape.uproject” -WaitMutex -FromMsBuild” exited with code 6.
1>Done building project “BuildingEscape.vcxproj” – FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

************************ unreal engine ************************
CompilerResultsLog: Error: C:/Users/GL63/Documents/Unreal Projects/BuildingEscape/Source/BuildingEscape/PositionReport.h(8) : Error: #include found after .generated.h file - the .generated.h file should always be the last #include in a header
Warning: HotReload failed, recompile failed
LogAudioMixer: Warning: Changing default audio render device to new device: {0.0.0.00000000}.{5ba07b60-329b-47bc-8cf6-2c8c0b708cba}.
LogAudioMixer: Warning: Changing default audio render device to new device: {0.0.0.00000000}.{f0bff4ed-e25d-4be1-9848-f8fa8ac17802}

Errors are telling you the issue, move this include up:
#include “GameFramework/Actor.h”

1 Like

Thanks,
this worked but what is reason behind to keep the header # include “GameFramework/Actor.h”
tag on top of code lines.

just a requirement of unreal engine I believe. and it’s more the generated.h has to be last, than the other on top.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms