Pointer to incomplete class type is not allowed

It seems that after cutting out the public sections of the base class, I got an error of “pointer to incomplete class type is not allowed” with both the BaseMesh and TurretMesh pointers on these lines in PawnBase.cpp:

BaseMesh->SetupAttachment(RootComponent);
TurretMesh->SetupAttachment(BaseMesh);

and another error of "argument of type “UStaticMeshComponent *” is incompatible with parameter of type “USceneComponent *” for the following line:

ProjectileSpawnPoint->SetupAttachment(TurretMesh);

I don’t know why this would be the case since no code related to these classes seems to have moved, but adding

#include "Components/StaticMeshComponent.h"

seems to fix it. Any ideas why this is?

Because you need the #include for this code. Try compiling without the the required #includes, and you will get errors like this.
For more info, see this link -
http://kantandev.com/articles/ue4-includes-precompiled-headers-and-iwyu-include-what-you-use#:~:text=A%20couple%20of%20engine%20versions%20back%2C%20Epic%20introduced,made%20and%20how%20they%20applied%20to%20game%20projects.

Thanks for the link. I was bothered by the fact that the instructor did not have these #includes, which made me think something else was going on. But it seems that your explanation of precompiled headers from transitive dependencies may be at play on the author’s machine, and my machine was just being vocal about it.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms