Many different possible #includes?

For the current lecture, I was also able to make the code work with at least one other #include:

#include "Engine/LocalPlayer.h"

I’m going with what Mike says, to be consistent with all the other stuff we’re doing later down the line.
But this did get me thinking: I don’t really know what I’m including, and whether by using Engine/LocalPlayer instead of GameFramework/PlayerController, I might be storing up trouble for later.

So I guess have a general question. Given that there’s often numerous functions that do the same thing, in different #includes, is there a way to know in advance what we’re enabling and what we aren’t? Or is this something that just comes time and lots of use of Unreal?

That would mean that that header includes what you need. #include is just a dumb copy and paste.
Say for example “Foo.h” includes “Bar.h” if I include “Foo.h” I would indirectly be including “Bar.h”.

// Foo.h:

#pragma once
#include "Bar.h"`
// SomeFile.cpp

#include "Foo.h" // will also include Bar.h

You needed to include GameFramework/PlayerController.h because you’re using the type APlayerController and that is the header in which it is defined.

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

Privacy & Terms