A call to an immediate function is not a constant expression

Hi!

I’m trying to compile an older plugin from version 5.4 into version 5.8 and I get this error:

C:\Users\me\source\MyProject\Plugins\MaxQ\Source\Spice\Private\SpiceData.cpp(381,63): error C7595: "UE::Core::Private::FormatStringSan::TCheckedFormatStringPrivate<FString::FmtCharType,int,const FString::ElementType *,long,long>::TCheckedFormatStringPrivate": A call to an immediate function is not a constant expression
            if (ErrorMessage) *ErrorMessage = FString::Printf(TEXT("Blueprint request for BODY%s_%s Expected double[%d] but proc returned double[%d]"), bodyid, *item, N, n_actual);
                                                              ^
C:\Program Files\Epic Games\UE_5.8\Engine\Source\Runtime\Core\Public\String\FormatStringSanErrors.inl(13,1): note: The error was caused by an undefined function call or an undeclared 'constexpr'
X(SNeedsWideCharPtrArg, "'%s' expects `TCHAR*`.")
^
C:\Program Files\Epic Games\UE_5.8\Engine\Source\Runtime\Core\Public\String\FormatStringSanErrors.inl(13,1): note: check use of 'UE::Core::Private::FormatStringSan::TCheckedFormatStringPrivate<FString::FmtCharType,int,const FString::ElementType *,long,long>::PRINTF_FORMAT_STRING_ERROR'
C:\Users\me\source\MyProject\Plugins\MaxQ\Source\Spice\Private\SpiceData.cpp(381,63): note: the call queue for the assessment (the oldest call) is
            if (ErrorMessage) *ErrorMessage = FString::Printf(TEXT("Blueprint request for BODY%s_%s Expected double[%d] but proc returned double[%d]"), bodyid, *item, N, n_actual);
                                                              ^
C:\Users\me\source\MyProject\Plugins\MaxQ\Source\Spice\Private\SpiceData.cpp(381,63): note: when evaluating the function 'UE::Core::Private::FormatStringSan::TCheckedFormatStringPrivate<FString::FmtCharType,int,const FString::ElementType *,long,long>::TCheckedFormatStringPrivate<8(const CharType (&)[81])'
        with
        [
            CharType=FString::FmtCharType
        ]
C:\Program Files\Epic Games\UE_5.8\Engine\Source\Runtime\Core\Public\String\FormatStringSanErrors.inl(13,1): note: when evaluation the function 'void UE::Core::Private::FormatStringSan::TCheckedFormatStringPrivate<FString::FmtCharType,int,const FString::ElementType *,long,long>::PRINTF_FORMAT_STRING_ERROR(const char *)'
X(SNeedsWideCharPtrArg, "'%s' expects `TCHAR*`.")
^
C:\Users\me\source\MyProject\Plugins\MaxQ\Source\Spice\Private\SpiceData.cpp(381,63): note: The context in which the template instances are created (oldest first) is
            if (ErrorMessage) *ErrorMessage = FString::Printf(TEXT("Blueprint request for BODY%s_%s Expected double[%d] but proc returned double[%d]"), bodyid, *item, N, n_actual);
                                                              ^
C:\Users\me\source\MyProject\Plugins\MaxQ\Source\Spice\Private\Spice.cpp(781,17): note: See the reference on creating an instance of the template function "void MaxQ::Data::Bodvcd<FSMassConstant>(ValueType &,int,const FString &,ES_ResultCode *,FString *)" it is compiling
        with
        [
            ValueType=FSMassConstant
        ]
    MaxQ::Data::Bodvcd(ReturnValue, bodyid, item, &ResultCode, &ErrorMessage);

But I have no idea how to fix it.

Any idea?

Thanks!

Try replacing the “if” in the SpiceData.cpp(381,63) with this:

if (ErrorMessage)
{
    *ErrorMessage = FString::Format(
        TEXT("Blueprint request for BODY{0}_{1} Expected double[{2}] but proc returned double[{3}]"),
        { bodyid.ToString(), *item, N, n_actual }
    );
}