Hi, I want to report a bug I discovered today. I make use of C++ interfaces and also implement them im Blueprints.
(There is some “special” behaviour which was a great deal to discover for me: See also here)
I now defined a C++ interface and declared a method which takes a FString parameter (among other ones). I did not implement it yet by any Object. But I already call the auto-generated Execute_XXX method from a Pawn.
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category = "Command")
bool ExecuteLocationCommand(FString CommandName, ...);
The compilation was the first one after the interface method was declared (if that is relevant). So interface method and calling code got compiled together (thus, Execute_XXX was not known by IntelliSense).
if (Selection.IsValid() && Selection.Get()->GetClass()->ImplementsInterface(URTSCommandInterface::StaticClass()))
{
IRTSCommandInterface::Execute_ExecuteLocationCommand(Selection.Get(),
TEXT("MoveTo"), LastHitResult.ImpactPoint);
}
The compilation threw an error in InterfaceXXX.gen.cpp. Since I did not provide a default implementation, there seems to be an autogenerated one, which i.a. checks that you don’t call it directly but with Execute-Prefix. And this autogenerated implementation had another signature as the original defined one (const FString& instead of String). Hence, I got a compiler error. Changing the parameter type in my declared function solved this and is definitely better, but still it caused an error.
If this is wanted behaviour, please document it somewhere, so one knows that he has to pass Strings by const-ref