Alright so I kind of fixed it but still have no idea why it was happening.
I went back and looked at the error about ScaleWithStat_StatType not existing. It’s type is an enum that I forward declared. I removed the forward declare and just imported the enum header and compiled and it worked. So I guess something wrong with forward declaring that specific enum type? No idea.
But to try and find out why forward declaring only worked based on the UPROPERTYs in a while different file I did some tests:
As for switching the order of the properties:
It seems like if there is more than 1 UPROPERTY between Icon and RequiredLevel, I get the compile error. If there is only 1, doesn’t matter what it is, then it will compile fine.
I moved RotateCasterToDirectionKey and RotateCasterToCamera to the bottom of the file, the last UPROPERTYs.
And this worked:
but having them both:
caused the error again.
I tried changing INT to int32, no difference.
Totally confused but not using that forward declare fixes it so I’ll settle for that I guess.
Really weird… its getting lost on how to deal with the struct showed in that error… forward declaration should still work… well at least you found a workaround! Well keep an eye on this and test some on my own codes.
usually I use int32 instead of INT as someone mentioned.
You can also do bools as
This will make C++ use a 32 bit int as a giant bitmask combining all the bools of the class into one int. It may save some space at the expense of a small perf hit since it has to read from a bitmask rather than a bool directly.
It’s more likely that there’s a weird missing comma or something somewhere in the UPROPERTY() defs. UE4 compiler errors can be really confusing when you’re missing something simple like GENERATED_BODY() at the top of your UCLASS definition. After years of knowing how to fix C/C++ compiler errors I now have to learn how to fix UE4 compiler errors too. It becomes easier to know what weird thing you’re missing the more experience you get. Hopefully it’s something stupid like that and you’ll be back on your way.
(Oh wait I missed the other reply where you fixed it by including the enum header, I never actually tried forward declaring an enum but I assume you can’t unless it’s a pointer or a reference)
In my experience forward declarations of enums and structs don’t work. The reason it may have worked before is because under the hood UE4 can merge source files before compiling to reduce compile time. This is called “unity build”. The reason why it broke suddenly is then because after small code changes can cause the unity build to combine the files together in a different way. So by chance the unity build took care of an include you were missing, and by chance it stopped doing that after different files were combined.
To disable unity build, go to your project’s MyProject.Target.cs and add to the constructor:
bUseUnityBuild = false;
Try compiling once in a while with unity build disabled, it may reveal some more missing includes which would have randomly turned up later.