#include not working - `'LFDateTime': is not a class or namespace name

Hi, I tried searching and have tried a number of things but to no avail. I am including DateTime.h in a file and I am getting the following error: 'LFDateTime': is not a class or namespace name

I have tried the following #include paths:

  • Runtime/Core/Public/Misc/DateTime.h
  • Core/Public/Misc/DateTime.h
  • Public/Misc/DateTime.h
  • Misc/DateTime.h
  • DateTime.h

I have tried including them in both the .cpp file and the .h file. I have also tried including Core.h and CoreMinimal.h above them and by themselves. I wouldn’t expect most of these solutions to work, I’m just saying I’ve tried them.

Currently, my files are as follows:

MyClass.h

#include "GameFramework/Actor.h"
#include "Manager.generated.h"
UCLASS()
class TERRAINGENERATION_API AManager : public AActor
{
	GENERATED_BODY()
public:	
	AManager();
protected:
	virtual void BeginPlay() override;
public:	
	virtual void Tick(float DeltaTime) override;
};

MyClass.cpp

#include "Manager.h"
#include "Misc/DateTime.h"

AManager::AManager() {
 	PrimaryActorTick.bCanEverTick = true;
}
void AManager::BeginPlay() {
	Super::BeginPlay();	
}
void AManager::Tick(float DeltaTime) {
	Super::Tick(DeltaTime);
	if (GEngine) {
		GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, TEXT(FDateTime::Now()));
	}
}

Thank you so much for your help!! I am new to C++ development in general and this is driving me crazy.

you just need to include Engine.h to access the GEngine. once this is done the correct use of AddOnScreenDebugMessage is GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FDateTime::Now().ToString());

Unfortunately, this is incorrect. GEngine is already working, and I am able to print debug messages. The problem is the error 'LFDateTime': is not a class or namespace name. (my guess is it’s being imported through CoreMinimal.h, which I have imported in my main project file, though I haven’t verified)

Have you tried my way?

Yes, I did try adding #include "Engine.h", and also adding the .toString() call on the FDateTime object. I appreciate your time and I’m willing to try anything. This is extremely frustrating.

I don’t see the #include "CoreMinimal.h" in your header file and be sure that .ToString() is not .toString()

I have also tried it with #include "CoreMinimal.h" in the header file and it did not work, unfortunately.

on my end when I add the CoreMinimal.h to the header and when I replace Misc/DateTime.h by Engine.h in the cpp file after compile I can create a blueprint that inherits from this class and when I add it to my scene I’m instantly flooded by messages on my scree.