USTRUCTs only working when NOT using GENERATED_BODY() macro?
Has anyone ever had weird behavior with Visual Studio compiling USTRUCTs?
I kept getting this error while modifying a plugin's USTRUCTs.
missing type specifier - int assumed
I was able to compile again after lots of head scratching. I have no idea why but with GENERATED_BODY() inside the structs throws the above error when compiling.
BUT then I comment out the GENERATED_BODY() lines and it compiles. Then I make any changes to the code and it refuses to compile saying it expects the GENERATED_BODY() macro. Macro is then uncommented and it will compile.
After discovering this last night I had to do this comment and uncomment dance every time I compiled.
I was able to package my game and test and things are working but this behavior seems really bizarre and I'm afraid something is wrong.
Here is the entirety of the file in question. I'm thinking it's a circular dependency like /u/p30virus.
**UPDATE:**
I nuked everything, including the plugin and recreated the project and re-installed the plugin. I setup all my classes and tested functionality and things are working fine.
For fun I tried to edit the enum for the plugin's inputs again after compiling all my classes with no issues. It appears that trying to add my own entries into the enum are what breaks things.
Here is the plugin's .h file which just defines some GAS input bind names and container specs for use with Epic's GAS plugin:
// Copyright 2021 Mickael Daniel. All Rights Reserved. #pragma once
#include "CoreMinimal.h" #include "Abilities/GameplayAbilityTargetTypes.h" #include "GameplayTagContainer.h" #include "GSCTypes.generated.h"
class UGSCTargetType; class UGameplayEffect;
/** List of Ability Inputs ID */ UENUM(BlueprintType) enum class EGSCAbilityInputID : uint8 { None UMETA(DisplayName = "None"), Confirm UMETA(DisplayName = "Confirm"), Cancel UMETA(DisplayName = "Cancel"), Ability1 UMETA(DisplayName = "Ability1") };
/** * Struct defining a list of gameplay effects, a tag, and targeting info * * These containers are defined statically in blueprints or assets and then turn into Specs at runtime */ USTRUCT(BlueprintType) struct FGSCGameplayEffectContainer { GENERATED_BODY()
public: FGSCGameplayEffectContainer() {}
/** Sets the way that targeting happens */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = GameplayEffectContainer) TSubclassOf<UGSCTargetType> TargetType;
/** List of gameplay effects to apply to the targets */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = GameplayEffectContainer) TArray<TSubclassOf<UGameplayEffect>> TargetGameplayEffectClasses;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = GameplayEffectContainer) bool bUseSetByCallerMagnitude = false;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = GameplayEffectContainer) FGameplayTag SetByCallerDataTag;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = GameplayEffectContainer) float SetByCallerMagnitude = 1.0f; };
/** A "processed" version of GSCGameplayEffectContainer that can be passed around and eventually applied */ USTRUCT(BlueprintType) struct FGSCGameplayEffectContainerSpec { GENERATED_BODY()
public: FGSCGameplayEffectContainerSpec() {}
/** Computed target data */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = GameplayEffectContainer) FGameplayAbilityTargetDataHandle TargetData;
/** List of gameplay effects to apply to the targets */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = GameplayEffectContainer) TArray<FGameplayEffectSpecHandle> TargetGameplayEffectSpecs;
/** Returns true if this has any valid effect specs */ bool HasValidEffects() const;
/** Returns true if this has any valid targets */ bool HasValidTargets() const;
/** Adds new targets to target data */ void AddTargets(const TArray<FHitResult>& HitResults, const TArray<AActor*>& TargetActors); };
If I try to add my own entry IE: Fire UMETA(DisplayName="Fire") (with matching tab spacing) I get this error:
>Building 7 actions with 4 processes... > [1/7] Module.BermudaSector.gen.1_of_4.cpp >z:\ue_4.26\engine\plugins\marketplace\gascompanion\source\gsc\public\abilities\GSCTypes.h(32): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int >z:\ue_4.26\engine\plugins\marketplace\gascompanion\source\gsc\public\abilities\GSCTypes.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int > [2/7] Module.BermudaSector.gen.2_of_4.cpp >z:\ue_4.26\engine\plugins\marketplace\gascompanion\source\gsc\public\abilities\GSCTypes.h(32): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int >z:\ue_4.26\engine\plugins\marketplace\gascompanion\source\gsc\public\abilities\GSCTypes.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int > [3/7] Module.BermudaSector.gen.3_of_4.cpp >z:\ue_4.26\engine\plugins\marketplace\gascompanion\source\gsc\public\abilities\GSCTypes.h(32): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int >z:\ue_4.26\engine\plugins\marketplace\gascompanion\source\gsc\public\abilities\GSCTypes.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int > [4/7] Module.BermudaSector.cpp >z:\ue_4.26\engine\plugins\marketplace\gascompanion\source\gsc\public\abilities\GSCTypes.h(32): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int >z:\ue_4.26\engine\plugins\marketplace\gascompanion\source\gsc\public\abilities\GSCTypes.h(59): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int