How do you pass a Ustruct to a c++ function

I have a ustruct

#pragma once
#include "TD.h"
#include "Structures.generated.h"

USTRUCT(BlueprintType)
struct F_Int_2D_Vector
{
	GENERATED_USTRUCT_BODY()
public:
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "F_Int_2D_Vector Struct")
	int32 X;
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "F_Int_2D_Vector Struct")
	int32 Y;

	F_Int_2D_Vector() { X = -1; Y = -1; }
	F_Int_2D_Vector(int32 xx, int32 yy)
	{
		X = xx;
		Y = yy;
	}
};

this works in the c++ and blueprints, the function SolveGrid however here is the class and declaration:

#include "TD.h"
#include "The_Pather.h"
//#include "Engine/DataTable.h"
#include "GameFramework/Actor.h"
#include "GridSolver.generated.h"
UCLASS()
class TD_API AGridSolver : public AActor
{
	GENERATED_BODY()
private:
	The_Pather *my_pather;
public:
	// Sets default values for this actor's properties
	AGridSolver();
	TArray<F_Int_2D_Vector> result;

	virtual void BeginPlay() override;
	virtual void Tick(float DeltaSeconds) override;

	UFUNCTION(BlueprintCallable, meta = (DisplayName = "Solve Grid", CompactNodeTitle = "Solve Grid", Keywords = "Solve Grid"), Category = Game)
	void SolveGrid(int32 start_x, int32 start_y, int32 finish_x, int32 finish_y, F_Int_2D_Vector *result);

	UFUNCTION(BlueprintCallable, meta = (DisplayName = "Setup Grid", CompactNodeTitle = "Setup Grid", Keywords = "Setup Grid"), Category = Game)
	TArray<int> setup_grid(TArray<FString> grid);

};

function:

 void AGridSolver::SolveGrid(int32 start_x, int32 start_y, int32 finish_x, int32 finish_y, F_Int_2D_Vector *result)
{
	my_pather->SolveGrid(start_x,start_y, finish_x, finish_y);

}

Won’t compile with the parameter (F_Int_2D_Vector *result) in place it throws a OtherCompilationError(5)

You need to include Structures.h in AGridSolver

a good thought but Structures.h is included in The_Pather.h
the line:
TArray result;
works and compiles fine so it’s not that, I wish it were that simple

Try deleting your intermediary folder, then right click your .uproject and generate project files. Then try rebuilding.

Hey Glass_Baine-

OtherCompilationError(5) is a general message that means the error that occurred isn’t something that has an error code related to it. You can check the Output log for more information in the majority of situations that involve this message.

I’ve never had much luck working with FStruct pointers; try referencing the struct instead:

SolveGrid(int32 start_x, int32 start_y, int32 finish_x, int32 finish_y, F_Int_2D_Vector& result);

Also, the compiler may be complaining because you never actually use the result argument in the method:

void AGridSolver::SolveGrid(int32 start_x, int32 start_y, int32 finish_x, int32 finish_y, F_Int_2D_Vector *result)
 {
     my_pather->SolveGrid(start_x,start_y, finish_x, finish_y);
 
 }

You use all the ints, but never touch the struct. Try actually using it and see if it compiles then; and if you don’t need it, then of course get rid of it.

tried that may times nothing sadly

nope neither of those work, good thought’s though, It was originally used in the function but I took it out to simplify the problem

Thanks for the thought, unfortunately the output log is just as vague

Can you copy the results from the Visual Studio output log after the failed compile. If possible, let me know if you’re able to reproduce the issue in a new, clean project.

Try changing the argument name. You have a class member called result, and you’re passing in an argument called result:

in your header, just below the constructor declaration:

TArray<F_Int_2D_Vector> result;

And your method declaration:

void SolveGrid(int32 start_x, int32 start_y, int32 finish_x, int32 finish_y, F_Int_2D_Vector *result);

I bet the compiler doesn’t know which “result” you want to use and is crying foul.