USTRUCT for multiple inherit

#pragma once

#include "CoreMinimal.h"
#include "Engine/DataTable.h"

#include "Item.generated.h"

USTRUCT(BlueprintType)
struct MYPROJECT FItem {
	GENERATED_USTRUCT_BODY()
}

USTRUCT(BlueprintType)
struct MYPROJECT FItemRow : public FTableRowBase, public FItem {
  GENERATED_USTRUCT_BODY()
};

compile it will get error: Missing ‘{’ in ‘struct’

but the follow two case is ok.

  1. remove USTRUCT
USTRUCT(BlueprintType)
struct MYPROJECT FItem {
	GENERATED_USTRUCT_BODY()
}

// USTRUCT(BlueprintType)
struct MYPROJECT FItemRow : public FTableRowBase, public FItem {
  GENERATED_USTRUCT_BODY()
};
  1. inhert one struct
USTRUCT(BlueprintType)
struct MYPROJECT FItem {
	GENERATED_USTRUCT_BODY()
}

USTRUCT(BlueprintType)
struct MYPROJECT FItemRow : public FTableRowBase {
  GENERATED_USTRUCT_BODY()
};

Is this a bug?

From what I know, the Unreal header tool / macros only work for single inheritance, except for when implementing interfaces.

That being said, in general, it seldom actually works out right to inherit multiple from structs – generally, aggregation (members) works better IMO.

2 Likes

Thanks for your reply.

I would try to avoid inheriting multiple structs.

Also don’t use GENERATED_USTRUCT_BODY is deprecated and just forwards to GENERATED_BODY so use that as they may (highly unlikely) remove the old one.

2 Likes

You are getting a compile error because of the missing ‘;’ semi colon at the end of FItem.

USTRUCT(BlueprintType)
struct MYPROJECT FItem {
	GENERATED_USTRUCT_BODY()
}

Oh, sorry, because I entered the code manually.

Thanks