(BUG) unrealheadertool bug when including a file twice

Hello,
i have a strange bug in Visual Studio. I tried to start a little mathlibary with static functions. But it didnt work out from beginning. First it told me it couldnt find the implentation (source mising or stuff(ais if u have a func-dekleration but no def)). Then after trying around, and do just little things like renaming a class/filename i got an error that the scmath.generated. couldnt get accessed or once it got included twice! i had pragma once in it!

Actually there is a even stranger error. the parent class of the class where i use a static fnction from scmath.h got this error:

fatal error C1189: #error:
“USC_Actor_DecalActor.generated.h
already included, missing ‘#pragma
once’ in USC_Actor_DecalActor.h”
USC_Actor_DecalActor.generated.h(12):

fatal error C1189: #error:
“USC_Actor_DecalActor.generated.h
already included, missing ‘#pragma
once’ in USC_Actor_DecalActor.h”


when i remove the class out of my project it compiles like a charm :)(well i have to clean the projectfiles like interdimate and stuff first …)
srly no idea whats the problem causing here…

----h

#pragma once

#include "CoreMinimal.h"

#include "SCMath.generated.h"

/**
*
*/



UCLASS()
class USCMath : public UObject
{

//	GENERATED_UCLASS_BODY()
	GENERATED_BODY()
public:
	USCMath(const FObjectInitializer& ObjectInitializer);
	USCMath() {};

//	static bool FVector_Angle_CalculateAngleDegreeOn_XYPlane_ToXAxis(FVector &v1, float &fReturn);
	bool CalculateAngleDegreeOn_XYPlane(FVector &v1, float &fReturn);
};

—cpp

#include "SCMath.h"
#include "CoreMinimal.h"
#include "Math/UnrealMathUtility.h"




 //bool FSMath::FVector_Angle_CalculateAngleDegreeOn_XYPlane_ToXAxis(FVector &v1,  float &fReturn)
USCMath::USCMath(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{

}

 bool USCMath::CalculateAngleDegreeOn_XYPlane(FVector &v1, float &fReturn)
 {
	 FVector vXAxis = FVector(1, 0, 0);

	 fReturn = (acosf(FVector::DotProduct(v1, vXAxis)));

	 if (fReturn > 50 && fReturn < 120)
	 {
		 fReturn = fReturn;
	 }
	 return true;
	 //	float fAimAtAngle = FMath::RadiansToDegrees(acosf(FVector::DotProduct(v1, v2)));
	 //	fAimAtAngle = acosf(FVector::DotProduct(v1, v1)); // == PI

 }

I got it solved out.
I have some juntionfolders in my source folder, so can use cpp easly on different projects.
But from the projectcreation when i was totally new to ue4 i still had included the same files via game.build.cs:

PrivateIncludePaths.Add("L:/classes/UnrealServiceClasses");

The Problem was that i didnt realize it and that the error showed on weired situations(after i added a new class, an error showed in another class and when i removed it the error was gone).

I wont change the status of the thread, because the staff may want to take a look into it.
Because i think it is still a bug. Which might could easly solved by better error handling/output or just by warning the user that the generated.h got included from 2 files. (#pragma once and include_guards didnt work, which they mabe should ?)

Hi,
I’m hitting this error now trying to bring in a plugin that was built on an older engine version. The plugin was built and runs fine in 4.18.3, but when I copy it over to a project built for 4.21, it fails with this error.

Can you please give more detail as to how you debugged this? The log result doesn’t give much information other than this error, and I’m fairly new to unreal build process.

Thank you.

the same issue happens after 4.23 upgraded to 4.24 but header file has “#pragma once”

Just a PSA :

Had the same error happen to me when I accidentally copied a header file into the solution twice (in different places)!
So, if you were copying around header files, this might be the cause.

1 Like