Like the title said, this is about an additional issue with Unreal 4.16 and the IWYU framework in Visual Studio 2017. Just to quickly summarize, you need to add a new #include in your .cpp file for each type of GameFramework Object that you need to use. One of the most common one that we’ll be adding is the Actor.h file. That was all stated in the update video.
Where the issue comes from is if you rely on the autocomplete portion. As your typing your new include line, if you autocomplete GameFramework, it’ll also include a backslash. Finishing the line, it’ll look like this:
#include "GameFramework\Actor.h"
This will cause an error when you try to compile in Unreal, but it doesn’t in VS.
To fix the error, it must be a forward slash, like so:
#include "GameFramework/Actor.h"
This second line will compile in both VS and Unreal.
I’m having massive problems with this.
Without adding #include “GameFramework\Actor.h” , it seems fine (but GetOwner isn’t doing as expected - as described) - but I have no errors:
But as soon as I add that include - errors everywhere…:
(hope you can see those screenshots - first time using Jing!
The errors are caused by the placement of the #include - any #includes with “generated” in the name need to be last in the list. I’ve found that when VS errors are unintelligible, compiling with the button in Unreal can sometimes give you more helpful messages; I had this same error and it actually told me exactly what the problem was.
Thanks proto, that helped… Its been really weird. I did what you suggested - but Visual Studio still had lots of squiggies and errors - but it built cleanly… The squigglies didn’t go away - so I tried changing the direction of the slash as mentioned earlier - which gave build errors.
But when I changed it back, and re-built it - it was all good. Visual Studio seemed to be behaving (no squigglies) and it was correctly listing the methods for GetOwner.
Thank you for this answer, I was having a similar problem to Brian with VS showing errors with when including GameFramework/Actor.h, placing the line earlier in the list in the header file seems to have cleared all errors and the code compiles in both VS and UE, and I can now access the AutoCompletes for GetOwner.
Thanks also to @binksayres for the initial post!
I wanted to add one additional thing to this. Due to the backslash issue, you can set Visual Studio to default to Forward Slash in the #include autocomplete. The image is for Visual Studio 2017, but this option is found in previous versions of Visual Studio as well. The page I found this at is:
Note, the Options dialog is found under the Tools pull down menu. And the image of the setting is here: