Looks like a mismatch in round bracket count.
Double check your plugin source code to see if you didn’t go overzealous with closing brackets. Could be a double closing )) where a single one would suffice.
That code I added to the OP was copy pasted right out of my plugin right at the place where I get this error. What is very strange though, is that I get this error EVERYWHERE in my plugin where I call GetSubsystem but when I try to fix it in ONE place, the error goes away everywhere else also…
So check this out… This is what causes me the problem
UWpServerGlobals* globals = GetWorld()->GetGameInstance()->GetSubsystem<UWpServerGlobals>();
if (globals)
{
globals->SetCookie(HeaderValue);
}
I simply do this in one file and all other files no longer give me that problem when I hit Package… But now when I build in VS I get an error saying:
static_assert failed: 'TSubsystemClass must be derived from TBaseType'
I have no clue what to do. Even though VS now gives me an error when I hit Build, the Outpul Log shows me I have 0 errors and 0 warnings and , oh yeah, BUILD FAILED with no clue why
Oh, and in case this is important, my subsystem is defined like so:
UCLASS()
class WORDPRESSSERVER_API UWpServerGlobals : public UGameInstanceSubsystem
It could be a phrase that is already in use? This could throw off the compiler if it is already defined as a macro of some sort.
Another thing to consider
In the source of the Engine UCommonUISubsystemBase that derives from UGameInstanceSubsystem when invoking the get command the current game instance seems to be passed along as an internal parameter even though it’s class definition structure is like your subsystem.
Thanks, I’ll try these other variants and see if they work.
At least you noticed the big question mark hanging over my head. When I use game instance it compiles perfectly fine for me in VS, just like it does for you… but then it gives me the ) errors when I try to package the plugin. When I use the World then the packaging process stops complaining but then I get compilation errors in VS. Totally weird.
But yeah, let me see if using gamesplaystatics or the game instance directly to get the subsystem works out any better.
Thanks for the tip!
EDIT:
Turns out this syntax works just fine for both cases:
UGameInstance* GI = UGameplayStatics::GetGameInstance(GetWorld());
UWpServerGlobals* SubSystem = UGameInstance::GetSubsystem<UWpServerGlobals>(GI);
I now have 0 errors or warnings both in VS and when packaging the plugin. Only issue now is that I still get BUILD FAILED but with no clue as to why Guess I need to go read all those normal message logs and see if anything gives me a clue.
Thanks for the assist, bru. Greatly appreciated!
EDIT 2:
I found I actually have MANY errors when I try to Package my plugin. They are written in white so I didn’t notice them right away. Now that I know to look for them I am finding many errors but they are truly stupid errors to have and it makes no sense to me why I have them… Some examples:
error C2065: 'GEngine': undeclared identifier
error C2027: use of undefined type 'UGameInstance'error
error C2027: use of undefined type 'FTimerManager'
I have to manually add #includes to Engine/World.h and even to GEngine ??? I mean… WTAF? Also,When I call GetGameInstance(GetWorld()) it says it doesn’t want a variable, it wants an expression
C2275: 'UWpServerGlobals': expected an expression instead of a type
…but it seems happy enough if I cast UWorld to UObject… These errors make no sense!
The GameInstanceSubsystem include wasn’t needed for the VS build but it was needed for the Packaging
So I am not sure if I should continue this thread or not because:
A) Everything now builds/compiles/packages. Everything works now
B) But the original question still remains: Why does the Packaging process throw out errors while the build process doesn’t (and the project actually runs perfectly). Why that discrepancy?
But yeah, at least I managed to work around the original issue by using the code you suggested so even though I don’t understand why it was needed, at least my project can now be built and distributed. Would have loved to understand why this workaround was needed , though
Do you have any editor only modules in your plugin that are not filtered in the target / build file?
These can throw a wrench in the packing process as editor only stuff like UnrealEd will trigger an error on pack. You need to then split the plugin into segments and only pack the non editor parts for the game.
Have 2 versions of the plugin one for the game and another for the editor and set different conditions in the uproject for when to load what.
I have an old project that does this, if you are still having problems with it and it could be the case then I can pack and send it to you for analysis.
I have 5 modules in my plugin, each module is meant to be used at runtime.
Two classes derive from UGameInstanceSubsystem
Most of them derive from UObject or UUserWidget
One of them derives from USaveGame
And the rest derives from UWpServer (one of the plugin classes which derives from UObject)