adding includes in header files

Every time I add an include in a header file I have to exit out of my IDE and unreal, re-generate visual studio files, reboot unreal, update visual studio files, and recompile from unreal before I can build from my IDE. Is there a way of getting around this issue? It’s really slowing me down when I code and makes debugging stuff on the fly a real pain.

There’s no reason you should have to do this, but generally speaking you want as few includes in your header files as possible (use forward declaration as much as you can).

Note that making changes to header files does increase build times quite dramatically, and hot reload still doesn’t really work properly with header file changes either. Rebooting Unreal is expected unless you use hot reload, but you shouldn’t have to regenerate project files.

Changing a header should go like this:

  1. Close unreal
  2. Wait 3 seconds
  3. Click build
  4. Start unreal again

As @TheJamsh said, you only need to regenerate the solution if:

  • You changed your .Build.cs file.
  • You “physically” added a new file and want it in the project (this is not the same as simply adding a #include)

Use forward declarations when you can get away with it and keep as many #includes in your source (.cpp) files as possible.

Thanks for the replies; I guess I am just used to conventional C++; I’ve always put all of my includes in my header files and left a single include in my definition files. I will try and use forward declares as often as possible now.