Error: Unrecognized type 'FHnsLobbyInfo' - type must be a UCLASS, USTRUCT or
UENUM
I tried including the header file in different places (above or below other includes) but nothing seems to work. No problems in the header file where I declare it, and no errors there.
Is it possible that the editor tries to compile the header file with the delegate before it compiles the file with the struct? I did some research but nothing worked, rebuilt the project files several times, tried other names, tried it with and without struct in the delegate, tried not using USTRUCT(BlueprintType) but nothing.
Struct keyword is for declaring a new struct type, or forward-declaring it. If you already have/included its declaration, you don’t need to redeclare it.
It was simply forward declaration! I had 5 circular dependency errors when the project compiled, it still launched before, but now it had probably more fatal errors wih the headers.
For those who might run into this (or for myself if I mess it up again):
So you might included some header files in each other, and what happens is that the UnrealHeaderTool cant decide exactly which file to compile first, so some data may not even be accessible or it will be but just not in the right order which might lead to the same thing, some variables (or something else) will be undefined/inaccessible.
To fix this, first, when compiling check for circular dependency errors, if there is any, search for them and remove them from unecessary header files. (there are includes that you should not include in the header, instead in the CPP (I always included every header in the header files, never in CPPs, and thats sometimes a mistake, sometimes you need other header files only in the CPP))
Second, in some header files where you had circular dependency error, you might need to use forward declaration like this:
/*dont include ATest header here if you had circular dependency error before, you might just need forward declaration like below, test it */
#include "HnsBeaconClient.generated.h"
//forward declaration
class ATest;
And, all this solves my original error with the delegate that didnt find my struct from another file, it was probably inaccessible .