C++ Compile Error

I’m learning C++ at the moment, And I’m trying to convert a Blueprint code to C++. My Event Update Room Scale Position is implemented as BlueprintImplementableEvent and BlueprintCallable. So I can Implement the event in the blueprint. Here is the Image of the Blueprint.

Now I am trying to covert this blueprint code to c++
Here is the Function in the .h file

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Character Movement")
	FVector LastRoomScalePosition = FVector(0.f,0.f,0.f);

UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Character Movement")
	void UpdateRoomScalePosition();

and in the .cpp file

void ABasePawn::UpdateRoomScalePosition()
{
	FRotator DeviceRotation;
	FVector DevicePosition;
	UHeadMountedDisplayFunctionLibrary::GetOrientationAndPosition(DeviceRotation,DevicePosition);
	FVector Position = LastRoomScalePosition - (DevicePosition.X, DevicePosition.Y, 0.f);
	CapsuleComponent -> AddWorldOffset(FVector(Position), false, nullptr, ETeleportType::None);
	LastRoomScalePosition = FVector(DevicePosition.X, DevicePosition.Y, 0.f);

}

I don’t know if this is correct way of how the code is as I used docs and searching google to workout how to construct the c++ code.

But when I build the code I get these errors

BasePawn.gen.cpp.obj : warning LNK4006: “public: void __cdecl ABasePawn::UpdateRoomScalePosition(void)” (?UpdateRoomScalePosition@ABasePawn@@QEAAXXZ) already defined in BasePawn.cpp.obj; second definition ignored

BasePawn.gen.cpp.obj : error LNK2005: “public: void __cdecl ABasePawn::UpdateRoomScalePosition(void)” (?UpdateRoomScalePosition@ABasePawn@@QEAAXXZ) already defined in BasePawn.cpp.obj

Everything is here :

already defined in BasePawn.cpp.obj;
second definition ignored

Make a search in your file, you defined this function two time.

Thank you for the reply Aherys_ .I checked. It is only defined once. Unless it is also counting the blueprint.

This is not, compiler is always right.

Try to change the function name to see.

1 Like

BlueprintImplementableEvent can’t have an implementation in C++.

2 Likes

Ok I’ll try that, thank you Aherys_ . I might even try to change it from a BlueprintImplementableEvent to a standard function.

Ok for those whom get the same problem. The Error was that I had made the Function a BlueprintImplementableEvent which is not a C++ Function. It is only a Blueprint Function.

1 Like