Download

Why don't I need to include headers in 4.15 anymore?

I just upgraded my project to 4.15 and VS2017 and I’ve noticed something very strange. I don’t need to include headers other than the standard ones any more.

By standard, I mean in my .h file I have the #include “MyActor.generated.h” and in the .cpp file I have the #include “MyProject.h” and #include “MyActor.h”

But beyond that, I don’t need to include any other project headers files any more. I can write code in my .h and .cpp files that clearly is referencing other actors and such from other source files, yet I am not including their headers at all and everything compiles and runs without complaining.

I’m kind of confused by this so I assume there must be some other project wide pre-compiled header going on somewhere that I can’t see or something like that. Can anyone explain?

I don’t know about VS2017 but that sounds like a global user search path for headers. Might be worth investigating

Have you tried packaging yet?

On the very contrary… I must include exactly every single header now.
Your report sounds pretty weird to me, after IWYU set in place.

Do you have them included in your Project.h file?
Or maybe your project is large enough that it decided to use unity build, and something else already included them?

I’m on the same boat as Bruno. Now that I’m no longer including Engine.h I have to add every header of every class I’m using, which is actually fine even though sometimes it takes a bit to find out where the definition is as I’m not using Visual Studio.

Clean your Intermediate and Saved folders for both the project and the engine. I’ll wager you’ll get hit with a million include errors right away.

I’ve spent hours figuring out all the headers for a medium sized project. I bet there’s something off in your story :stuck_out_tongue:

I tried creating a new blank project and added a couple of classes to it and it works as expected. If I try to use something from one class in the other without a header include I get errors as expected.

So I tried wiping out everything bar the Content, Source and Config folders in my main project, then regenerating the project files. I then rebuilt the project still with no errors!?!?! I blatantly have files using classes from other files with no header includes or nested header includes! What is happening. It is a pretty large project now as I’ve been working on it for a while now.

Maybe this new IWYU foo is causing odd things. I don’t have any includes in my project header, just the Engine.h. Maybe I should get rid of the Engine.h and start including individual Engine header files?

Skipping including Engine.h will make it quicker when it comes to compiling… but you’ll definitely have to include all the single headers as you need them.

Include Engine/Engine.h instead of the public Engine.h;
If you still have the same results than this a case for the X-Files tv series.