build failed while creating new c++ class

  Log file: C:\Users\jimts\AppData\Local\UnrealBuildTool\Log.txt
  Creating makefile for projeightEditor (no existing makefile)
  Parsing headers for projeightEditor
    Running UnrealHeaderTool "C:\ueproj\projeight\projeight.uproject" "C:\ueproj\projeight\Intermediate\Build\Win64\projeightEditor\Development\projeightEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -abslog="C:\Users\jimts\AppData\Local\UnrealBuildTool\Log_UHT.txt" -installed
  C:/ueproj/projeight/Source/projeight/CPP_Object.h(11): Error: When compiling class definition for '', attempting to strip prefix results in an empty name. Did you leave off a prefix?
Build failed.

I face this error while trying to create a new class from an object or an actor.
Can anyone help? Thanks.

1 Like

The error message suggests that there is an issue with the class definition for an object declared in the header file. The error specifically indicates that there is an attempt to strip a prefix that results in an empty name.

It’s hard to tell without seeing the code in the header file but it’s likely that there is a typo or syntax error in the code leading up to the class definition that is causing the issue. Check the code carefully for any such errors.

I literally did nothing since its my first attempt of creating a c++ class. I just clicked tools->new c++ class-> actors->set the name, and thats what I got.

It did generated a .h and .cpp file for me, be nearly 10k errors occured within it, mainly about it can’t find the header files. Here are the codes.

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "CPP_MyActorC.generated.h"

UCLASS()
class PROJEIGHT_API ACPP_MyActorC : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	ACPP_MyActorC();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

};

// Fill out your copyright notice in the Description page of Project Settings.


#include "CPP_MyActorC.h"

// Sets default values
ACPP_MyActorC::ACPP_MyActorC()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void ACPP_MyActorC::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void ACPP_MyActorC::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

Hello, I have the same problem. Have you managed to solve it, if so, please tell me how?