C++ File Structure

Hi! I have some questions about how to structure my C++ files.

I’m currently working on an RPG using C++, so naturally I have an ability base class, and a character base class. Each ability instance must have a caster reference, so it can pass information to any effects it creates or to affected targets when it is cast, and each character has a list of abilities. This means that the ability base class header #includes the base character header, and the base character cpp (not the header, otherwise circular dependencies are an issue) contains the base ability header.

Now, I have my build.cs file configured so that a full recompile isn’t performed with every compilation, only files that have changed. However, the way I’ve structured my code above means that if I make even the most trivial of changes to my character base class and recompile, Visual Studio spends a good 10-15 minutes recompiling every single ability in the game (as well as all my characters, but that I can understand).

With that said, are there any pointers about the way I should structure my header files to avoid unnecessary recompilation time? I’ve heard that you can split code into modules, and compile each module separately, but I don’t know anything beyond that about that system, so is that worth looking into?

You should look up forward declarations, they will massively reduce the amount of actual includes you need in your headers. For example, including the character header in the ability header is not necessary just because it has a pointer to one.

Modules don’t really reduce your compile times - you still got the same amount of headers and source files, just ending up with two dlls instead of one. In huge projects, like the engine itself, this would speed up link times if only one has to be rebuilt.

15 minutes sounds extremely high regardless, that’s nearly as long it takes for me to build the engine. Is the project and engine on an SSD? Maybe a CPU upgrade is in order?