繁体   English   中英

如何在 c++ UE4 中修复错误“类似函数的宏调用‘TEXT’的参数过多”

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

我正在尝试打印包含编译器将找到的对象名称的消息。 我收到一条错误消息,说我必须为宏调用等函数提供许多参数。 我要结束关于 udemy 的 turorial 这里是视频的链接: https ://www.udemy.com/unrealcourse/learn/v4/t/lecture/4590240?start =0

我试过这个代码:

#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);


}

有没有办法阻止这个错误的发生?

您的变量参数需要在 TEXT() 宏的括号之外,如下所示:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM