x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Struct Class Not Recognized

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!

Product Version: UE 4.15
Tags:
more ▼

asked Jun 07 '17 at 02:25 PM in C++ Programming

avatar image

Ronin Inc
18 1 3 7

avatar image Ronin Inc Jun 07 '17 at 03:06 PM

To add a bit more detail. I have another header file that contained the struct "FInventoryItem", and this seems to compile just fine. Only "FCraftingInfo" or any struct made in the "CraftingStation.h" file gives the error.

avatar image Reuben Ward Jun 07 '17 at 03:53 PM

Just realized this is my Source code :D Hope the tutorial is going well

avatar image Ronin Inc Jun 07 '17 at 04:34 PM

Haha thanks Rueben, it was going pretty well until I hit somewhere near the end where I cant get the structs to register in the GameplayController. But this probably due to me experimenting with it and adding some child objects of AInteractable that weren't in the tutorial.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

I kept at the problem and corrected it with the following steps:

  • Removed the code from the files. Saved, and recompiled without it.

  • Added code back in manually and saved.

  • After this the same code compiled fine.

Not sure if this will help anyone but that is what corrected it.

more ▼

answered Jun 14 '17 at 03:18 PM

avatar image

Ronin Inc
18 1 3 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

You have a cyclic include. CraftingStation.h includes GameplayController.h, which in turn includes CraftingStation.h.

Either break up your files so you can access the types you need without this cycle, or see if you can use a forward declaration of your type instead (you can if you only need a pointer or reference to your type in your header).

more ▼

answered Jun 07 '17 at 03:28 PM

avatar image

Jamie Dale STAFF
7.4k 176 66 304

avatar image Ronin Inc Jun 07 '17 at 03:54 PM

Thanks!

I removed the include to gameplaycontroller.h from craftingstation.h, however the error remains the same.

avatar image Jamie Dale STAFF Jun 07 '17 at 04:19 PM

What includes do Interactable.h, CraftingGameGameMode.h, and CraftingGameCharacter.h have?

avatar image Ronin Inc Jun 07 '17 at 04:27 PM

Interactable.h #include "GameFramework/Actor.h" #include "Engine/DataTable.h" #include "Interactable.generated.h"

CraftingGameMode.h #include "GameFramework/GameModeBase.h" #include "CraftingGameGameMode.generated.h"

CraftingGameCharacter.h #include "GameFramework/Character.h" #include "Engine/DataTable.h" #include "CraftingGameCharacter.generated.h"

avatar image Jamie Dale STAFF Jun 07 '17 at 04:53 PM

Hmm, I can't see any other obvious cycles, and it's actually UHT which is producing the error about what looks like a perfectly valid USTRUCT type.

One thing you might try is deleting your Intermediate folder (you'll need to re-generate projects after doing this). This will clean out all the UHT generated files and force it to re-parse everything (just in case the cycle got its cache in a weird state).

avatar image Ronin Inc Jun 07 '17 at 05:06 PM

I gave that a go, but I am still getting the same error. I will try to keep looking for a work around.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question