# Array of Interfaces, blueprintable c++ function parameter

**URL:** <https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489>\
**Category:** UI\
**Tags:** interface, macros, unreal-engine, Scripting, question, CPP\
**Created:** [October 7, 2015, 3:52am UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489 "2015-10-07T03:52:40Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hennez](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hennez](https://forums.unrealengine.com/u/Hennez)\
**Post date:** [October 7, 2015, 3:52am UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/1 "2015-10-07T03:52:40Z")

</div>

Having some issues getting an array of interfaces as a function parameter for a function tagged as “BlueprintCallable”

The following works if the function is NOT tagged as blueprint callable, ie:

```
void MyFunction(TArray<TScriptInterface<IInterface>> foo);

```

But if you try to make it integrate with blueprint, as an example like so:

```
UFUNCTION(BlueprintCallable, Category = Debug)
void MyFunction(TArray<TScriptInterface<IInterface>> foo);

```

It will refuse to compile.

I’m just wondering what the generally accepted syntax is to do this?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [October 7, 2015, 7:27pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/2 "2015-10-07T19:27:37Z")

</div>

Hey Hennez-

It should be possible to create a function that accepts an array as a parameter. What is the exact error you get when trying to compile with the UFUNCTION() in place?

---

<div class="post-metadata">

**Author:** ![Hennez](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hennez](https://forums.unrealengine.com/u/Hennez)\
**Post date:** [October 7, 2015, 11:29pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/3 "2015-10-07T23:29:27Z")

</div>

Hey , thanks for responding -

The error is:  
TScriptInterface’ : unspecialized class template can’t be used as a template argument for template parameter ‘InElementType’, expected a real type

Also edited the question, realised it had butchered the examples since I didn’t have them as code segments, you should be able to make more sense of the examples now.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [October 8, 2015, 1:50pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/4 "2015-10-08T13:50:01Z")

</div>

Hey Hennez-

Have you taken a look at the documentation for exposing interfaces to blueprints? If you are having problems getting this to compile you may want to check out this link for how to setup an interface in code and access it through blueprints: [A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums](https://wiki.unrealengine.com/Expose_an_interface_to_blueprint)

Cheers

---

<div class="post-metadata">

**Author:** ![Hennez](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hennez](https://forums.unrealengine.com/u/Hennez)\
**Post date:** [October 8, 2015, 10:01pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/5 "2015-10-08T22:01:45Z")

</div>

Hey ,  
Thanks for the link, though the issue here isn’t to do with the interface set-up. The interface is set-up and exposed to blueprint all fine, I can call it’s functions etc. This is more specific to passing a reference to that interface, and more specifically again an array of them.

The following code for instance works fine to pass a single reference of an interface:

```
UFUNCTION(BlueprintCallable, Category = Debug)
 void MyFunction(TScriptInterface<IInterface> foo);

```

But it’s not recognizing it as a ‘real’ parameter type when I add on the TArray at the front.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [October 9, 2015, 5:42pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/6 "2015-10-09T17:42:04Z")

</div>

Hey Hennez-

After further investigation it seems that there is a bug with passing an array of interfaces into a function. This bug has been recorded for further investigation (UE-21971).

Cheers

---

<div class="post-metadata">

**Author:** ![alk3ovation](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alk3ovation](https://forums.unrealengine.com/u/alk3ovation)\
**Post date:** [November 17, 2015, 12:03am UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/7 "2015-11-17T00:03:35Z")

</div>

I’m having this same issue. +1 for a solution!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [November 17, 2015, 3:30pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/8 "2015-11-17T15:30:37Z")

</div>

Hey alk3ovation-

I have entered a bug for this issue (UE-21971) and noted the increased interest in a fix. Unfortunately there isn’t a workaround for passing an array of interfaces at this time.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_31953c13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_31953c13](https://forums.unrealengine.com/u/anonymous_user_31953c13)\
**Post date:** [December 16, 2015, 4:22pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/9 "2015-12-16T16:22:55Z")

</div>

Any update on this ? Seems to still be an issue in 4.10.1

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [December 16, 2015, 7:58pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/10 "2015-12-16T19:58:19Z")

</div>

Hey -

This issue is still open in our database. I have added a comment to the bug report to indicate that this is still affecting people and will update here when there is a change in the status.

Cheers

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_31953c13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_31953c13](https://forums.unrealengine.com/u/anonymous_user_31953c13)\
**Post date:** [December 16, 2015, 11:10pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/11 "2015-12-16T23:10:42Z")

</div>

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_31953c13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_31953c13](https://forums.unrealengine.com/u/anonymous_user_31953c13)\
**Post date:** [December 16, 2015, 11:26pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/12 "2015-12-16T23:26:14Z")

</div>

Oh, I just discovered another problem with TScriptInterface. If you try to define a blueprint native like this:

UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = Skill Management")  
void GetSkill(TScriptInterface foo);

virtual void GetSkill\_Implementation(TScriptInterface foo);

and then in your cpp you define \_Implementation (as usual):

void MyClass::GetSkill\_Implementation(TScriptInterface foo) { … }

And then try to compile it will complain about  
“GetSkill(const TScriptInterface &)': overloaded member function not found”

---

<div class="post-metadata">

**Author:** ![Hennez](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Hennez](https://forums.unrealengine.com/u/Hennez)\
**Post date:** [December 16, 2015, 11:52pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/13 "2015-12-16T23:52:44Z")

</div>

Hey ,

Pretty sure this is just a case of the UHT changing the parameters slightly, it does it with TScriptInterface\<\> and TArray\<\> that I’ve noticed.

When you define the function, try giving it what it wants, so instead of:

```
 void GetSkill(TScriptInterface foo)

```

try using:

```
 void GetSkill(const TScriptInterface<>& foo)

```

and it should compile and work for you

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_31953c13](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_31953c13](https://forums.unrealengine.com/u/anonymous_user_31953c13)\
**Post date:** [December 17, 2015, 1:51pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/14 "2015-12-17T13:51:06Z")

</div>

You’re right - I didn’t initially notice that it complained about not finding reference type. Changing my functions to use reference instead of value fixes it. Thanks

---

<div class="post-metadata">

**Author:** ![UnrealEverything](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnrealEverything](https://forums.unrealengine.com/u/UnrealEverything)\
**Post date:** [January 27, 2016, 5:59pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/15 "2016-01-27T17:59:13Z")

</div>

The dev-team is probably already aware of this, the problem is that the generated code in .generated.h is incorrect.  
A function like this:

.h

```
UFUNCTION(BlueprintCallable, Category = "My Category")
void MyFunction(TArray<TScriptInterface<IMyInterface>> const & Parameter);

```

becomes (note the first argument for the P\_GET\_TARRAY\_REF macro (which is supposed to be the type):

.generated.h

```
#define <path to file>_h_<line number of GENERATED_BODY() macro>_RPC_WRAPPERS[_NO_PURE_DECLS] \
 \
 ...\
	DECLARE_FUNCTION(execMyFunction) \
	{ \
		P_GET_TARRAY_REF(TScriptInterface,Z_Param_Out_Parameter); \
		P_FINISH; \
		this->MyFunction(Z_Param_Out_Parameter); \
	} \
 ...

```

One workaround could be to wrap the parameter in a USTRUCT or simply provide a CustomThunk yourself. Simply mark your UFUNCTION with the CustomThunk specifier ([https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Functions/Specifiers/CustomThunk/index.html](https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/Reference/Functions/Specifiers/CustomThunk/index.html)) and add this code to your .h (for my example above):

```
DECLARE_FUNCTION(execMyFunction)
{
	P_GET_TARRAY_REF(TScriptInterface<IMyInterface>,Z_Param_Out_Parameter);
	P_FINISH;
	this->MyFunction(Z_Param_Out_Parameter);
}

```

That works for me, hope it helps someone else encountering this.

---

<div class="post-metadata">

**Author:** ![UnrealEverything](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnrealEverything](https://forums.unrealengine.com/u/UnrealEverything)\
**Post date:** [June 3, 2016, 6:56am UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/16 "2016-06-03T06:56:58Z")

</div>

So I’ve just encountered this problem again yesterday. This time I decided to take a closer look and see what I could do to fix it once and for all. As it turns out only very few lines are needed to handle this specific case.  
I’ve submitted a [Pull Request #2468](https://github.com/EpicGames/UnrealEngine/pull/2468) with the necessary changes.  
If you don’t want to wait, [here is the commit](https://github.com/UnrealEverything/UnrealEngine/commit/b5a52d8b6b83fccc0d7eb820db85774664e10084)

Edit: forgot to mention, my change is based on the 4.11.0 release branch

---

<div class="post-metadata">

**Author:** ![zamy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zamy](https://forums.unrealengine.com/u/zamy)\
**Post date:** [July 27, 2016, 2:02pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/17 "2016-07-27T14:02:05Z")

</div>

Thanks. Hope they will integrate it soon.

---

<div class="post-metadata">

**Author:** ![zamy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zamy](https://forums.unrealengine.com/u/zamy)\
**Post date:** [July 27, 2016, 2:21pm UTC](https://forums.unrealengine.com/t/array-of-interfaces-blueprintable-c-function-parameter/334489/18 "2016-07-27T14:21:56Z")

</div>

Just to let it known, i temporarly resolved it copy/pasting the generated code and modifying it (using CustomThunk).

Example:

```
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, CustomThunk, Category = "MyHUD")
	void MyOnSelectionChange(class UMainInGameWidget* MainHUD, const TArray<TScriptInterface<IEntityInterface>> & CurrentSelection );
	virtual void MyOnSelectionChange_Implementation(class UMainInGameWidget* MainHUD, const TArray<TScriptInterface<IEntityInterface>> & CurrentSelection);
	DECLARE_FUNCTION(execMyOnSelectionChange)
	{
		P_GET_OBJECT(UMainInGameWidget, Z_Param_MainHUD); 
		P_GET_TARRAY_REF(TScriptInterface<IEntityInterface>, Z_Param_Out_CurrentSelection); 
		P_FINISH; 
		this->MyOnSelectionChange_Implementation(Z_Param_MainHUD, Z_Param_Out_CurrentSelection);
	}
```
