So, although I haven’t seen any official source state that this is the case, and although I have seen a few instances of knowledgeable people stating that it is not the case, my experience has been that USTRUCT will fail to compile if the name immediately following struct does not begin with a capitol “F”.
Cases that led me to this conclusion:
(Modified code from the USTRUCT tutorial.)
USTRUCT()
struct FParticleStruct
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
AActor* CameraPtr;
UPROPERTY()
float LifeTime;
UPROPERTY()
bool doTransitionalBlending;
//For GC
void Destroy()
{
CameraPtr = nullptr;
}
//Constructor
FParticleStruct()
{
CameraPtr = NULL;
LifeTime = -1;
doTransitionalBlending = true;
}
};
The above compiles. (VS 2013 Pro)
USTRUCT()
struct ParticleStruct
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
AActor* CameraPtr;
UPROPERTY()
float LifeTime;
UPROPERTY()
bool doTransitionalBlending;
//For GC
void Destroy()
{
CameraPtr = nullptr;
}
//Constructor
ParticleStruct()
{
CameraPtr = NULL;
LifeTime = -1;
doTransitionalBlending = true;
}
};
The above does NOT compile.
USTRUCT()
struct FRackadackablah
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
AActor* CameraPtr;
UPROPERTY()
float LifeTime;
UPROPERTY()
bool doTransitionalBlending;
//For GC
void Destroy()
{
CameraPtr = nullptr;
}
//Constructor
FRackadackablah()
{
CameraPtr = NULL;
LifeTime = -1;
doTransitionalBlending = true;
}
};
Compiles.
USTRUCT()
struct Rackadackablah
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
AActor* CameraPtr;
UPROPERTY()
float LifeTime;
UPROPERTY()
bool doTransitionalBlending;
//For GC
void Destroy()
{
CameraPtr = nullptr;
}
//Constructor
Rackadackablah()
{
CameraPtr = NULL;
LifeTime = -1;
doTransitionalBlending = true;
}
};
Does not.
In all non-compiling cases the errors reported is:
Error 1 error code: OtherCompilationError (5)
Error 2 error MSB3073: The command ""C:\Program Files\Epic Games\4.8\Engine\Build\BatchFiles\Build.bat" MyProjectEditor Win64 Development "C:\Users\John\Documents\Unreal Projects\MyProject\MyProject.uproject" -rocket" exited with code -1.
What am I missing?