无法正确导出 custom UStruct: Error C4430 : missing type specifier - int assumed. Note: C++ does not support default-int
Closed this issue · 1 comments
ZezhongWang commented
Describe the bug
在尝试导出自定义UStruct时遇到了编译错误:
Error C4430 : missing type specifier - int assumed. Note: C++ does not support default-int
Version
Unreal Engine 5.2, Slua 2.1.4 Release
To Reproduce
我有一个自定义类:
USTRUCT(BlueprintType, meta = (DisplayName = "Intent", HasNativeMake="/Script/PaxDei.IntentFunctionLib.MakeIntent"))
struct FIntent
{
GENERATED_USTRUCT_BODY()
private:
/**
* Archetype name.
*/
UPROPERTY(VisibleInstanceOnly, Meta = (ArchetypeName, ArchetypeTags="intent"))
FName Type;
/**
* Serialization keys.
*/
inline static const FString KEY_TYPE = TEXT("type");
public:
/**
* Empty instance.
*/
FIntent() : Type(NAME_None) { }
/**
* From individual field values.
*/
FIntent(const FName& Type) : Type(Type) { }
/**
* From serialized JSON data.
*/
FIntent(const FJson& Json)
{
if (Json.IsValid())
{
Type = Json.Has<FName>(KEY_TYPE) ? Json.Get<FName>(KEY_TYPE) : NAME_None;
}
}
/**
* Returns the archetype type name.
*/
const FName& GetType() const
{
return Type;
}
/**
* TODO: Remove!!!
*/
void Clear()
{
Type = NAME_None;
}
/**
* Returns the string representation of the instance.
* Should be used for debugging purposes only.
*/
FString ToString() const
{
TArray<FStringFormatArg> Args;
Args.Add(FStringFormatArg(Type.ToString()));
return FString::Format(TEXT("FIntent { Type: {0} }"), Args);
}
/**
* Serializes to a JSON object.
*/
FJson ToJson() const
{
return FJson().Set(KEY_TYPE, Type);
}
bool operator == (const FIntent& Other) const
{
return Type.IsEqual(Other.Type);
}
bool operator != (const FIntent& Other) const
{
return !Type.IsEqual(Other.Type);
}
bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bSuccess)
{
Ar << Type;
bSuccess = true;
return true;
}
friend FArchive& operator << (FArchive& Ar, FIntent& Intent)
{
Ar << Intent.Type;
return Ar;
}
bool Serialize(FArchive& Ar)
{
Ar << *this;
return true;
}
};
然后我使用宏 DefTypeName 尝试导出它,在同一个 Intent.h 文件
namespace NS_SLUA {
DefTypeName(FIntent);
}
然后我获得了编译错误
0>Intent.h(122): Error C4430 : missing type specifier - int assumed. Note: C++ does not support default-int
ZezhongWang commented
发现是缺头文件。。。 #include "SluaUtil.h"
这个编译错误有些误导性