Search code examples
c++visual-studiounreal-engine4

How to fix error 'too many arguments for function-like macro invocation 'TEXT'' in c++ UE4


I am trying to print a message containing an objects name that the compiler will find. I am getting an error saying I have to many argument for function like macro invocation. I am going off a turorial on udemy here is a link to the video: https://www.udemy.com/unrealcourse/learn/v4/t/lecture/4590240?start=0.

I have tried this code:

#include "PositionReport.h"
#include "Gameframework/Actor.h"

UPositionReport::UPositionReport()
{

    PrimaryComponentTick.bCanEverTick = true;


}



void UPositionReport::BeginPlay()
{
    Super::BeginPlay();


    FString ObjectName = GetOwner()->GetName();
    //The error is right here
    UE_LOG(LogTemp, Warning, TEXT("Position report for %s!", *ObjectName));

}
void UPositionReport::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
    Super::TickComponent(DeltaTime, TickType, ThisTickFunction);


}

Is there a solution to stop this error from occurring?


Solution

  • Your variable arguments need to be outside the TEXT() macro's parens, like so:

    UE_LOG(LogTemp, Log, TEXT("Pathname: %s"), *UnrealPath);