Hi,
I’m trying to offload some work in my project to a new thread using an FRunnable based on this tutorial: https://wiki.unrealengine.com/Multi-Threading:_How_to_Create_Threads_in_UE4, but I’m running into all kinds of dependency problems.
So I have two classes: “AFowManager” which is responsible for spawning a “AFowWorker”. The headers look like this:
#include "GameFramework/Actor.h"
#include "FowManager.generated.h"
UCLASS()
class RPGTEST_API AFowManager : public AActor
{
GENERATED_BODY()
...
AFowWorker FowThread;
...
}
**************
class AFowWorker : public FRunnable
{
//Pointer to our manager
AFowManager* Manager;
So the FowManager needs to spawn the thread and it includes a pointer to itself which is fed into the constructor. I’ve tried to let the two classes include each other, I’ve tried adding both of the .h-files to the MyProject.h-file and included it in both of the headers, I’ve tried making a foreward declaration to the AFowWorker-class in the AFowManager-header, but I’m getting different permutations of the errors:
FowManager.h(76) : error C2079: ‘AFowManager::FowThread’ uses undefined class ‘AFowWorker’
FowManager.h(75) : error C2146: syntax error : missing ‘;’ before identifier ‘FowThread’
FowManager.h(75) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
The “funny” thing is that I do have other classes referencing each other, but these are all UCLASS()-annoted, whereas I’m getting a “Superclass not found”-error if I try annoting my FRunnable with a UCLASS.
If anybody would care to share some light on the matter it would be greatly appreciated.