Need Help: Making Multiple Structures inside cpp. class

I tried creating two structs inside my empty subclass, and I also aimed for both structs to be visible when creating new Data Table. I’m stuck on this however:


EDIT: Regenerating project files fixed the Expands To redirection (or something).

This is just visual studio struggling with unreal’s macros, you should be able to build fine

Not sure which version of VS you’re using, but the later versions are doing better with unreal, so check if there are updates available

Yeah it should be fine. Regenerating the project should also fix the underline near the .generated.h include

Engine: Unreal Engine 5.1.
I’m using VS 2022.

Here’s another issue I’m struggling with now:
Building is stuck on Running UnrealBuildTool: dotnet

Killing NET.Host progresses, removal of both EnemyInitParam files (cpp. and h.) from Source, and regenerating project files fixes this issue.

But I’m trying to make it build with those cpp. classes. And it doesn’t want to Built, when these EnemyInitParam files are inside Source.

I tried building the UCLASS, in attempt to fix this issue:



Reminder: trying to create a cpp. class that has Two Structures with variables, that I can use for Data Tables.

is Cnd_GD_EnemyInitParam supposed to be a component or a file containing structs?

Seems like you should just make your component class first => then add the structs to it. Or better yet extract them to only a separate header file that only includes the structs and include that into your proper component.

File containing Structures, that can be used for a new Data Table.

Well, it’s easy to make Structure via Blueprint approach, but I want via CPP.

Structures only require the header file (.h) There is no implementation side of the struct so no .cpp equivalent file is needed.

Oh and datatable entries don’t inherit from structs

USTRUCT(BlueprintType, Blueprintable)
struct FCnd_GD_EnemyInitParamBase : public FTableRowBase {
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	FText Em_Name;
};

I’ll need to install 5.1 to get a full version packed

So let me get this straight… for Data Tables in Pick Row Structure window, I can only pick the Structures generated via Blueprints, but not the ones made in CPP class.

How else I could make these structures in CPP class to appear in the Pick Row Structure window?

Example project with a struct that can be used in a datatable
Edit: updated the component file with inline structs that can also be used as entries
Conduit.zip (11.6 KB)

Generate vs project from uproject file.

You can generate from a struct but it has to extend FTableRowBase otherwise it will not show up as a variable to base off the datatable entry

And if you need it in a class of another file then just include the header in the cpp file (and forward declare in the header if needed)

“You can generate from a struct but it has to extend FTableRowBase”

And I forgot about adding: #include "Engine/DataTable.h"

Plus that cpp. file (not h.) prevented the UnrealBuiltTool from building the solution (and I tried to use it to set the Default Values in each struct).

I’m an idiot.

Hey, by the way, while I’m at the structs inside my header file… what are the cpp. counterparts of Variable Types for Actor Class Ref (Variable Named: EnemyClass) and Audio Component Class Ref (Variable Named: EnemyVoice)?

Could you explain more in detail? variables usually just have their definition in the headers of files, but if they are in structs then their is no cpp version of a struct.

Think of it as a container that is just used to bind elements in a group and used to transport them from part A to B somewhere in the code or to store information in a group.

Once you define a struct notice that it’s not a pointer to an object. You have direct access to it. You then populate it with variables and pointers as needed.

There usually is very little internal logic. You cannot put UFunctions in them if you want to expose them to blueprints.

As for what goes in headers and what in cpp

in headers try to put in the most simplified definition of the classes parameters. Limit the amount of includes and forward declare where you can, then put the needed includes in the cpp that complement the forward declarations.

in header forward declare under includes

// top of file inclues

class UBoxComponent;

// then start of code
UCLASS()
//// rest of class files

Then in cpp add the proper include

#include "Components/BoxComponent.h"

This will reduce circular dependencies.

This I mean to add in cpp. structure:


An Actor class reference, that I can use to assign Enemy Class BPs to it.

if you want a class reference then TSubclassOf is the c++ equivalent.

Though I would put soft references to classes in structs of type TSoftClassPtr, this will prevent hard references.