How to use HeaderGroup?

Hi, i am trying to add a MovementComponent in my project. I follow the example from the Shooter game, my header is like this :

#pragma once
#include "ShooterCharacterMovement.generated.h"

UCLASS(HeaderGroup = Component)
class UShooterCharacterMovement : public UCharacterMovementComponent
{
	GENERATED_UCLASS_BODY()

};

And the cpp file :

#include "DE_Game.h"

UShooterCharacterMovement::UShooterCharacterMovement(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
}

the problem is i have a bunch of error in my “DEGame.generated.inl” :

1>E:\DEGame\DEGame\degame\Intermediate\Build\Win64\Inc\DEGame\DEGame.generated.inl(24): error C2653: 'FDE_HUDStyle' : is not a class or namespace name
1>E:\DEGame\DEGame\degame\Intermediate\Build\Win64\Inc\DEGame\DEGame.generated.inl(30): error C2653: 'UDE_HUDWidgetStyle' : is not a class or namespace name
1>E:\DEGame\DEGame\degame\Intermediate\Build\Win64\Inc\DEGame\DEGame.generated.inl(30): error C3861: 'StaticClass': identifier not found
1>E:\DEGame\DEGame\degame\Intermediate\Build\Win64\Inc\DEGame\DEGame.generated.inl(34): error C2653: 'FDE_HUDStyle' : is not a class or namespace name

There is a lot more i just put some, but if i remove “HeaderGroup = Component” from "UShooterCharacterMovement " it compile without error.

It seems like i should use the HeaderGroup but i don’t understand how, do i need to add something somewhere else ? Also can someone explain what this meta is suppose to do ?

Thanks !

The HeaderGroup keyword specifies which generated header to put the definition in to. In the case of components it causes it to go to ShooterComponentClasses.h

This can be beneficial by allowing like headers to be batched together and not require each one to be included individually. However, it can cause you to have to do more rebuilding because if any of those headers change all files that include it must be recompiled even they didn’t actually rely on it.

Anyways, back to your problem at hand, you’ll see in ShooterGame.h that ShooterGameComponentClasses.h is included meaning that every file that includes ShooterGame.h (all of them pretty much) gets all the headers flagged as the HeaderGroup Component included automatically.

To solve your problem you can either add DEGameComponentClasses.h to DEGame.h, or add it before the generated.inl in the specific header in question, or not use the header group and include the header explicitly without using the geneated Classes.h

I did add “DEGameComponentClasses.h” and rebuild solution before posting the question. It looks like this :

#ifndef __DE_GAME_H__
#define __DE_GAME_H__

#include "Engine.h"
#include "EngineKismetLibraryClasses.h"
#include "ParticleDefinitions.h"
#include "SoundDefinitions.h"
#include "Net/UnrealNetwork.h"
#include "DEGameClasses.h"
#include "DEGameComponentClasses.h"

DECLARE_LOG_CATEGORY_EXTERN(LogGame, Log, All);

//#define COLLISION_PROJECTILE	ECC_GameTraceChannel1


#endif

I guess i can continue without using the HeaderGroup , but i would prefer find out what i’m doing wrong. I looked all the files from the ShooterGame example and also the “.Build.cs” file, but i don’t see anything more. Is there something else i can try ?