Build Error: Expected an include at the top of the header...

Hello all, and thanks in advance for any help you can provide. Some information:

  • UE 5.2
  • Blueprint Project
  • Using SixDOF Movement Component which has a long history.

I mention SixDOF Movement because the error below seems movement component related and it is a recent addition to my project. Everything works well in editor, and plays as expected, but I can’t build the project.

Issue:
Today, building my project for Windows 64 I got a build error. The complete error is:

UATHelper: Packaging (Windows): D:\Games\UE_5.2\Engine\Source\Runtime\Engine\Classes\GameFramework\CSFloatingPawnMovement.h(1): Error: Expected an include at the top of the header the follows all other includes: '#include "CSFloatingPawnMovement.generated.h"'

It looks like this in context: Error Log FWIW

I went as far as going into the file mentioned in the error, and adding that include, but then I get a “same-name” class conflict of some sort.

Any suggestions? Thanks again!

M

Greetings @GurneyHM02

There was a post with another use who had this same issue and found a solution. Here’s a link to the post. If this doesn’t resolve the problem, post back here and we can look into other alternatives.

Thank you for the response!

I did see that. I put the “CSFloatingPawnMovement.generated.h” include as the last line in the file: \Games\UE_5.2\Engine\Source\Runtime\Engine\Classes\GameFramework\CSFloatingPawnMovement.h to try to resolve the error. So that top section in the file now looks like:

#pragma once

#include "CoreMinimal.h"
#include "UObject/ObjectMacros.h"
#include "GameFramework/PawnMovementComponent.h"
#include "FloatingPawnMovement.generated.h"
#include "CSFloatingPawnMovement.generated.h"

Now when I build, it generates a new error:

Error: Class 'UFloatingPawnMovement' shares engine name 'FloatingPawnMovement' with class 'UFloatingPawnMovement

Even if I create a brand new UE 5.2 project from scratch, I get this error. I also verified my Unreal Engine install and all plugins (I only have one).

This was my fault! Not surprising. This response by a gentleman in the LootLocker Discord helped me out:

This seems unrelated to any LootLocker code. But in general for Unreal Engine; any code file in the project in the header you need to add include “.generated.h” as the last of the include statements. So without any knowledge of your project it seems to say that somewhere you have a code file named “CSFloatingPawnMovement.h” (and .cpp but we don’t care about that at the moment) and in that file you have either added #includes after the .generated one, or the .generated one is missing.
[10:56 PM]
Or for that matter you’ve changed the filename but missed changing it in the .generated line.

I had casually duplicated the FloatingPawnMovement.h file and Unreal did not like that. I wasn’t using it.

Thanks all - as you were :slight_smile:

2 Likes

Awesome! Were you able to get everything resolved?

Yes. I just deleted my copied class and everything compiled correctly.

Excellent! I’m glad that was able to get resolved! Have a great day!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.