# Functions with ustructs pointer as parameter, OtherCompilationError(5)

**URL:** <https://forums.unrealengine.com/t/functions-with-ustructs-pointer-as-parameter-othercompilationerror-5/77185>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [October 30, 2016, 1:52pm UTC](https://forums.unrealengine.com/t/functions-with-ustructs-pointer-as-parameter-othercompilationerror-5/77185 "2016-10-30T13:52:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glass\_Baine](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Glass\_Baine](https://forums.unrealengine.com/u/Glass_Baine)\
**Post date:** [October 30, 2016, 1:52pm UTC](https://forums.unrealengine.com/t/functions-with-ustructs-pointer-as-parameter-othercompilationerror-5/77185/1 "2016-10-30T13:52:00Z")

</div>

I am trying to write a function that takes a structure I created, and fills it :

```auto

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;
	}
};

```

I Can use this structure in the c++ and it works fine, I can also see this structure/ break it in the blueprint

This is the class definition:

```auto

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

};

```

This is the function definition

```auto

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

}

```

if i take out the last parameter from the function declaration it compiles fine if i add it i get OtherCompilationError(5)

---

<div class="post-metadata">

**Author:** ![Amimoller](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Amimoller](https://forums.unrealengine.com/u/Amimoller)\
**Post date:** [October 31, 2016, 6:26am UTC](https://forums.unrealengine.com/t/functions-with-ustructs-pointer-as-parameter-othercompilationerror-5/77185/2 "2016-10-31T06:26:22Z")

</div>

AFAIK you are not allowed to pass USTRUCTS by pointer, especially when its blueprintcallable. Pass it by reference instead.  
Also the output window in visual studio should tell you this.

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [October 31, 2016, 11:15am UTC](https://forums.unrealengine.com/t/functions-with-ustructs-pointer-as-parameter-othercompilationerror-5/77185/3 "2016-10-31T11:15:21Z")

</div>

Yup that’s correct, USTRUCTS can’t be passed this way though Blueprint functions. It will work with regular C++ functions, though.

You can’t safely store pointers to structs as member variables either.
