Missing '*' in Expected a pointer type

Hello,

I have this very simple code that refuses to compile and I have no idea why… The error says:
Missing ‘*’ in Expected a pointer type

If I remove the UFUNCTION(BlueprintCallable, Category = “BlinkerGameState”) line, then everything compiles fine.

I found some other threads with the same mistake but none with a similar case.

.h

#pragma once

#include "GameFramework/GameState.h"
#include "BlinkerGameState.generated.h"

UCLASS()
class BLINKER_API ABlinkerGameState : public AGameState
{
	GENERATED_BODY()
	
public:
	//================================
	// BLUEPRINT FUNCTIONS
	UFUNCTION(BlueprintCallable, Category = "BlinkerGameState")
	void SortPlayerStateByScore(TArray<APlayerState>& _PlayersToSort);
	//================================	
};

.cpp

// Fill out your copyright notice in the Description page of Project Settings.

#include "Blinker.h"
#include "BlinkerGameState.h"


void ABlinkerGameState::SortPlayerStateByScore(TArray<APlayerState>& _PlayersToSort)
{

}   

Any idea about what I’m doing wrong?

BlueprintCallable don’t allow to have reference in argument, so that is expected pointer for your case, so u can change to this if u want to use BlueprintCallable.

TArray<APlayerState*> SortPlayerStateByScore(TArray<APlayerState*> _PlayersToSort)
1 Like

Know this is a bit late, currently you need to use a uparam. Below is just an example setup with a few notes. There are probably some improvements to be made.

So the header example would be:

UFUNCTION(BlueprintCallable, Category = "BlinkerGameState") // If I need to override anything, I will include BlueprintNativeEvent at the start.
void SortPlayerStateByScore(UPARAM(ref) const TArray<APlayerState*>& _PlayersToSort);

And then for the implementation, I’d do:

void ABlinkerGameState ::SortPlayerStateByScore(UPARAM(ref) const TArray<APlayerState*>& _PlayersToSort)
// if using BlueprintNativeEvent this would change to: SortPlayerStateByScore_Implementation...
{
     // code to execute here.
}

:slight_smile: 我也遇到了这个错误,原因是代码的前面多加了个UFUNCTION()bir

UFUNCTION(BlueprintCallable, Category = "cmd")

UFUNCTION(BlueprintPure, Category = "Base|Regex")
static bool RegexMatch(const FString& Str, const FString& Pattern, TArray<FString>& Result);