Getting pointer to incomplete class type not allowed when getting Viewport

Hello, I am trying to get the viewport so that I may set the mouse position when the player releases the right mouse button. The only problem is that I keep getting the incomplete class type not allowed error. This is being done in my PlayerCharacter.cpp file. here is the code that is not working.

FViewport* Viewport = CastChecked(PlayerController->Player)->ViewportClient->Viewport;
Viewport->SetMouse(LastMousePosition.X, LastMousePosition.Y);

The underline error is underneath the CastChecked

Can someone help me fix this?

I found out the fix. All I had to do was change #include "EngineMinimal.h" to #include "Engine.h"

Incomplete class type in C++ means you using class which is declared without a structure definition (it’s incomplete)

class SomeClass; //Incomplete

class SomeClass {
     int X;
     int Y;
} //Complete

Compiler can’t compose code without knowing how to structure the class in memory, there for it won’t allow you to use it in most operation.

In case of UE4 where forward referencing frequently is used in header files, this error means you missed some include, which has definition of of specific class that triggers error (UPlayer? UViewport?), without that it only get type from forward reference (which is incomplte decleration) in one of header files.

Ah ok i’m slow typer :stuck_out_tongue: but below you got explanation