As someone very new to programming in C++ and in UE4, I have come across a bit of a hurdle that I cannot seem to find the answer to.
I have header file that references a struct defined in another header file. For some reason, even though the the headers reference each other in the “#include” section, for some reason when I try to call the struct in an array, I get the following output error in VS.
1>------ Rebuild All started: Project: CraftingGame, Configuration: Development_Editor x64 ------
1> Cleaning CraftingGameEditor Binaries...
1> Creating makefile for CraftingGameEditor (no existing makefile)
1> Performing full C++ include scan (no include cache file)
1> Parsing headers for CraftingGameEditor
1> Running UnrealHeaderTool "F:\Epic Games\Unreal Projects\CraftingGame\CraftingGame.uproject" "F:\Epic Games\Unreal Projects\CraftingGame\Intermediate\Build\Win64\CraftingGameEditor\Development\CraftingGameEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
1>F:/Epic Games/Unreal Projects/CraftingGame/Source/CraftingGame/GameplayController.h(36): error : Unrecognized type 'FCraftingInfo' - type must be a UCLASS, USTRUCT or UENUM
1>EXEC : error : UnrealHeaderTool failed for target 'CraftingGameEditor' (platform: Win64, module info: F:\Epic Games\Unreal Projects\CraftingGame\Intermediate\Build\Win64\CraftingGameEditor\Development\CraftingGameEditor.uhtmanifest, exit code: OtherCompilationError (5)).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(42,5): error MSB3073: The command ""F:\Epic Games\UE_4.15\Engine\Build\BatchFiles\Rebuild.bat" CraftingGameEditor Win64 Development "F:\Epic Games\Unreal Projects\CraftingGame\CraftingGame.uproject" -waitmutex" exited with code -1.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Here are my header files:
CraftingStation.h
#pragma once
#include "Interactable.h"
#include "GameplayController.h"
#include "Engine/DataTable.h"
#include "CraftingStation.generated.h"
/**
*
*/
UCLASS()
class CRAFTINGGAME_API ACraftingStation : public AInteractable
{
GENERATED_BODY()
public:
ACraftingStation();
UPROPERTY(EditAnywhere)
UStaticMeshComponent* StationMesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName ItemID;
protected:
};
USTRUCT(BlueprintType)
struct FCraftingInfo
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName ComponentID;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName ProductID;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyComponentA;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bDestroyComponentB;
};
USTRUCT(BlueprintType)
struct FCraftingInventory
{
GENERATED_BODY()
public:
};
And GameplayController.h, where the error is generated from.
#pragma once
#include "GameFramework/PlayerController.h"
#include "CraftingStation.h"
#include "CraftingGameGameMode.h"
#include "CraftingGameCharacter.h"
#include "GameplayController.generated.h"
/**
*
*/
UCLASS()
class CRAFTINGGAME_API AGameplayController : public APlayerController
{
GENERATED_BODY()
public:
//Reloads inventory after crafting
UFUNCTION(BlueprintImplementableEvent)
void ReloadInventory();
UFUNCTION(BlueprintCallable, Category = "Utilities")
void AddItemToInventoryByID(FName ID);
UFUNCTION(BlueprintCallable, Category = "Utilities")
void AddItemToStationInventoryByID(FName ID);
UPROPERTY(BlueprintReadWrite, VisibleAnywhere)
TArray<FInventoryItem> Inventory;
UPROPERTY(BlueprintReadWrite, VisibleAnywhere)
TArray<FCraftingInfo> CraftingInventory;
//the interactable the player is looking at. If none, nullptr
UPROPERTY(BlueprintReadWrite, VisibleAnywhere)
class AInteractable* CurrentInteractable;
protected:
virtual void SetupInputComponent() override;
void OnInteract();
void StopInteract();
};
Thanks in advance!