What to include (IWYU)

Hello guys,
I am quite unsure about what I should or should not include, I am more interested into best practices rather than definitions. I am converting my project to IWYU system.

My code uses Navigation headers, however I noticed all these headers are included in NavigationSystem which I use too. Should I include only NavigationSystem or should i explicitly list there all headers?

Good example is also AIController.h, it includes UObjectGlobals.h, so if I have child of AIController.h with FObjectInitializer constructor I don’t need to include UObjectGlobals.h in my cpp file.

Also, what are your tips and tricks when it comes to managing includes? :slight_smile:

Thanks

Include only the bare minimum required to compile, anything more is just adding compile time.

Are you using the methods of an object? Include it.
Are you just storing a pointer to that object? Forward declare it (if in a header file).

You also don’t want to rely on includes from other files, your code should be able to compile on its own. So with regard to your AIController example - I would include the UObjectGlobals.h as well just to be explicit that this code is using that class.

Thanks, thats valueable anwser. I think I will probably ignore includes for parent classes. So I will not be including AActor when I am sure that my parent is derived from AActor and so on.