Confused about IWYU

Going through this Unreal course and so far it is kind of a big mess. All this pre-work about getting the compiler issues straight and the headers etc – it is so unclear what is relevant /needed. In the “accessing object names” lecture they have this note attached to the video about needing to #include “Gameframework/Actor.h”. But I don’t get errors if I do not include that. The video afterward is super long and it’s unclear whether it is relevant to 4.2.2. If I’m not getting errors, how would I know if I need to go look for a header to speed things up?

Early in the next video about IWYU there’s a note at the top: “To skip the upgrade, go to 9:30”. What? I skipped to 9:30 just thinking that the video was for people coming from an older version, but at 9:30 it still makes no sense to me.

The issue is mainly regarding Intellisense.
If you are accessing members off a type then you need to include the header for that type.

GetWorld()->GetFirstPlayerController();

Here I’m accessing a member off of UWorld so would include that header for that type (Engine/World.h)

1 Like

If you see a #include note and are using UE 4.22 then yes you have to include it.

(Supposedly) unless of course you’re manually including engine.h which heavily slows down compiles. (I’ve not tried this as its not recommended.)

If you have errors after adding it then either you have problems with your code or VS hasn’t yet caught up to it and is just showing incorrectly.

You also must include it somewhere above the generated.h line.

This topic was automatically closed after 4 days. New replies are no longer allowed.

Privacy & Terms