Search code examples
c++visual-c++unreal-engine4

UE4 Data Table Struct Errors


I'm following a Packt tutorial regarding CSV table entry. The tutorial requires that I a) create a new Actor class, b) name it TestCustomData, and c) replace the contents of the newly-generated TestCustomData.h with the following code:

#pragma once

#include "TestCustomData.generated.h"

USTRUCT(BlueprintType)
struct FTestCustomData : public FTableRowBase
{
GENERATED_USTRUCT_BODY()

UPROPERTY( BlueprintReadOnly, Category = "TestCustomData" )
int32 SomeNumber;

UPROPERTY( BlueprintReadOnly, Category = "TestCustomData" )
FString SomeString;
};

However, the TestCustomData file fails to compile, outputting the following log:

Error f:\unreal\ue4 assignments\ue4_projectrpg\source\ue4_projectrpg\TestCustomData.h(5) : error C2504: 'FTableRowBase': base class undefined
Info Compiling game modules for hot reload
Info Parsing headers for UE4_ProjectRPGEditor
Info   Running UnrealHeaderTool "F:\Unreal\UE4 Assignments\UE4_ProjectRPG\UE4_ProjectRPG.uproject" "F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Intermediate\Build\Win64\UE4_ProjectRPGEditor\Development\UE4_ProjectRPGEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
Info Reflection code generated for UE4_ProjectRPGEditor in 3.4146568 seconds
Info Performing 4 actions (4 in parallel)
Info TestCustomData.cpp
Info UE4_ProjectRPG.generated.cpp
Error f:\unreal\ue4 assignments\ue4_projectrpg\source\ue4_projectrpg\TestCustomData.h(6) : error C3646: 'Super': unknown override specifier
Error f:\unreal\ue4 assignments\ue4_projectrpg\source\ue4_projectrpg\TestCustomData.h(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Error F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Source\UE4_ProjectRPG\TestCustomData.h(5) : error C2504: 'FTableRowBase': base class undefined
Error F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Source\UE4_ProjectRPG\TestCustomData.h(6) : error C3646: 'Super': unknown override specifier
Error F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Source\UE4_ProjectRPG\TestCustomData.h(6) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Info ERROR: UBT ERROR: Failed to produce item: F:\Unreal\UE4 Assignments\UE4_ProjectRPG\Binaries\Win64\UE4Editor-UE4_ProjectRPG-3031.dll
Info Total build time: 6.88 seconds (Local executor: 0.00 seconds)

I'm fairly new to StackOverflow and C++ in UE4, and any help would be appreciated. Any feedback to improve my question is also welcome! Thanks in advance for your help.


Solution

  • I was stuck at the same spot and this fixed it: I named the Asset "MyActor2" and the Strucure "ThisNewStructure" so there are some little differences...

    I think it was basicly including the Datatable.h and the "public:" that did the trick.

    Header File:

    #pragma once
    
    #include "CoreMinimal.h"
    #include "GameFramework/Actor.h"
    #include "Runtime/Engine/Classes/Engine/DataTable.h"
    #include "MyActor2.generated.h"
    
    USTRUCT(BlueprintType)
    struct FThisNewStructure : public FTableRowBase
    {
        GENERATED_USTRUCT_BODY()
    public:
    
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
            int32 SomeNumber;
        UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = test)
            FString SomeString;
    
    };
    

    cpp:

    #include "MyActor2.h"
    

    Then it compiles successful. I had to do some closing/reopening of VS & UE for the Editor to know about the new structure.