Different Unreal 4.17 Behavior

When pasting #include Tank.h above TankPlayerConroller.h in Unreal 4.17 it won’t compile as it specifically expects TankPlayerController.h to be the first header. Maybe this changed in the later versions of Unreal after the video was made.

C:\Users\ben_u\source\repos\UnrealCourse\04_BattleTank\BattleTank\Source\BattleTank\TankPlayerController.cpp(1) : error: Expected TankPlayerController.h to be first header included.

Hey,

It seems likely that your projects runs under the IWYU method:

TL;DR Instead of including the full Engine header file (Engine/Engine.h), each class includes only what it needs to function which is supposed to reduce compile time at the cost of a bit more complicated setup (you need to include individually each class header you’re using).

In addition to that, they emit a warning because you need to put the include for the class’ header first (to make sure the class is properly defined). The link above explains how to disable it, but you could also just put the header first :slight_smile:

If you have more questions let me know! I’m not an expert but I managed to swap my whole project to use IWYU!

1 Like

Privacy & Terms