I created a UStruct and when I try to use it as a variable/UProperty in other classes, it gives me the following errors:
1>d:\documents\unreal projects\megarisk\source\megarisk\Army/Army.h(41): error C3646: 'team': unknown override specifier
1>d:\documents\unreal projects\megarisk\source\megarisk\Army/Army.h(41): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
I’ve tried things like uppercase-ing the variable name and removing the UProperty macro, and I also tried making a property of a different struct. That last one worked, so I know it’s a problem with this specific struct. The other struct also had a default constructor and a LOCTEXT_NAMESPACE thing at the top.
I haven’t used plain USTRUCTs much, so I’m not sure how much help I can provide.
That said, two things jump out at me:
Your struct uses the GENERATED_BODY() macro where the ones I’ve used have the GENERATED_USTRUCT_BODY() macro. I think they resolve to the same thing, but you could try using the USTRUCT version just in case.
Your first error is about an override specifier. Your property declaration doesn’t include one of those, and I don’t think the UPROPERTY() macro will generate one either. This makes me wonder if there’s an error in one of the surrounding lines. Perhaps a missing semi-colon on the previous line, for example. Have you made sure the nearby lines are right, or tried declaring a new property (e.g. with a different struct) right before this one?
Anyway, I hope this helps and best of luck either way!
Are you able to post a few of the other lines surrounding the property declaration (apparently from Army.h)? That might be helpful.
Also, out of curiosity, have you tried moving the LOCTEXT_NAMESPACE bit below the #pragma once line? If that doesn’t help, you could try doing that in the other struct(s) too. I’d expect to see a different error if that was causing problems, but if I’m correctly inferring its purpose, it probably belongs below the #pragma once in any case.
If I had to hazard a guess, then I would associate it with your use of a namespace. #define LOCTEXT_NAMESPACE "team"
It does not know what an FTeamStruct is. Default-int comes from C, where if a return type isn’t specified it will return an int, and as it says C++ doesn’t support this, which essentially translates to not having a return type that it’s aware of.
If that isn’t the issue then you’ll need to pastebin the army.h.
In response to roomon1: GENERATED_USTRUCT_BODY() is obsolete, only not marked as such. GENERATED_BODY() is correct.
Unfortunately the one line that seems to be causing all the problems is #include "includes.h". includes.h is basically an stdafx file where I store all of my frequently used headers.
The way I have the code set up, I almost have circular dependency. An army (and a number of other things) has a team variable, and each team, in turn, has a variable/array of all objects belonging to that team. This makes it a lot easier to get an object’s team or all of the armies owned by a team.
Also, it seems that structs don’t like being used via includes.h. I tried putting the working SettingsVar struct into includes.h and I got errors similar to the ones I’ve been having with the Team struct.
I’ve got to go to bed now so I’ll try some stuff out tomorrow. Thanks for all the help.