What are best practices regarding c++ project folder structure?

During compiling after upgrading to 4.24 I was notified of a few engine changes and went about updating my code to account for depreciations. All was well, other than a default build setting that had changed:

[Upgrade]     bLegacyPublicIncludePaths = false                 => Omits subfolders from public include paths to reduce compiler command line length. (Previously: true).

As it says, setting this value to true will mess up your includes if you have split your files into multiple subdirectories.

My project source folder is as follows (Wall of text incoming):

C:.
β”‚   Game.Target.cs
β”‚   GameEditor.Target.cs
β”‚
└───Game
    β”‚   Game.Build.cs
    β”‚   Game.cpp
    β”‚   Game.h
    β”‚   GameCharacter.cpp
    β”‚   GameCharacter.h
    β”‚   GameCharacterAnimInstance.cpp
    β”‚   GameCharacterAnimInstance.h
    β”‚   GameGameInstance.cpp
    β”‚   GameGameInstance.h
    β”‚   GameGameMode.cpp
    β”‚   GameGameMode.h
    β”‚   HealthBar.cpp
    β”‚   HealthBar.h
    β”‚   LoginGameMode.cpp
    β”‚   LoginGameMode.h
    β”‚
    β”œβ”€β”€β”€Abilities
    β”‚   β”‚   ChanceProcAbility.cpp
    β”‚   β”‚   ChanceProcAbility.h
    β”‚   β”‚   SelfHealAbility.cpp
    β”‚   β”‚   SelfHealAbility.h
    β”‚   β”‚   SellfEffectAbility.cpp
    β”‚   β”‚   SellfEffectAbility.h
    β”‚   β”‚   SingleEffectAbility.cpp
    β”‚   β”‚   SingleEffectAbility.h
    β”‚   β”‚   UseIfEffectActive.cpp
    β”‚   β”‚   UseIfEffectActive.h
    β”‚   β”‚
    β”‚   └───Core
    β”‚           AbilityComponent.cpp
    β”‚           AbilityComponent.h
    β”‚
    β”œβ”€β”€β”€GameplayEffects
    β”‚   β”‚   MovementControlLossEffect.cpp
    β”‚   β”‚   MovementControlLossEffect.h
    β”‚   β”‚   ProcOverlayEffect.cpp
    β”‚   β”‚   ProcOverlayEffect.h
    β”‚   β”‚   StatEffect.cpp
    β”‚   β”‚   StatEffect.h
    β”‚   β”‚
    β”‚   └───Core
    β”‚           DOTEffect.cpp
    β”‚           DOTEffect.h
    β”‚           GamePlayEffectComponent.cpp
    β”‚           GamePlayEffectComponent.h
    β”‚
    β”œβ”€β”€β”€Lobby
    β”‚       LobbyGameMode.cpp
    β”‚       LobbyGameMode.h
    β”‚       LobbyPlayerController.cpp
    β”‚       LobbyPlayerController.h
    β”‚
    β”œβ”€β”€β”€Player
    β”‚   └───Core
    β”‚           GamePlayerController.cpp
    β”‚           GamePlayerController.h
    β”‚           PlayerCharacter.cpp
    β”‚           PlayerCharacter.h
    β”‚           PlayerCharacterAnimInstance.cpp
    β”‚           PlayerCharacterAnimInstance.h
    β”‚
    └───UserInterface
            AbilityBarItem.cpp
            AbilityBarItem.h
            EffectStackBar.cpp
            EffectStackBar.h
            EffectStackBarItem.cpp
            EffectStackBarItem.h
            HotBar.cpp
            HotBar.h
            LoginWidget.cpp
            LoginWidget.h
            WinnerOverlayWidget.cpp
            WinnerOverlayWidget.h

I’m assuming that by this upgrade being the new default, the way I’ve been going at it is not intended. It feels off to have everything in one folder. You can split it up in visual studio using filters, but every time you β€œGenerate project files” they are lost to the abyss.

So…

What are best practices regarding c++ project folder structure?

Bonus:

Any tips to smooth the transition to whatever is correct (seeing as my project is quite large)?

Thank you in advance!!! <3

Why can’t you split everything into folders? i do it and it works well in 4.24. You just have to be explicit, like

SomeSubFolder/SomeHeader.h

that is all the difference is. You can even put the include paths into your build.cs tho i dislike this.

Oh and that project is not quite large :smiley: we have around 1000+ code files :slight_smile:

1 Like

Thank your for the reply!!

I will look more closely in the morning. If i had been referencing headers without the path, i’ll have a good laugh.

Ok, I figured it out. As of 4.24, the following flag was changed to false.

[Upgrade]     bLegacyPublicIncludePaths = false                 => Omits subfolders from public include paths to reduce compiler command line length. (Previously: true).

TheKaosSpectrum was pretty much right. However you also need to include the module in your path:

Example:

Pre 4.24:

#include "Abilities/Core/AbilityComponent.h"

Post 4.24:

#include "Game/Abilities/Core/AbilityComponent.h"