UFUNCTION() with TMap or TSet argument causes generated code errors

I’m trying to do something ala this.

UFUNCTION()
void TestFunction(TMap<FName, FString> Test);

However, I get a series of errors with the GENERATED_BODY() as a direct result:

note xxx.h is header containing that function

xxx.h(40): error C2275: 'FName': illegal use of this type as an expression
x:\ue4\unrealengine\engine\source\runtime\core\public\UObject/NameTypes.h(522): note: see declaration of 'FName'
xxx.h(40): error C2275: 'FString': illegal use of this type as an expression
x:\ue4\unrealengine\engine\source\runtime\core\public\GenericPlatform/GenericPlatformSplash.h(34): note: see declaration of 'FString'
xxx.h(40): error C2065: 'Z_Param_Test': undeclared identifier
xxx.h(40): error C3861: 'P_GET_TMAP': identifier not found
xxx.h(40): error C2275: 'FName': illegal use of this type as an expression
x:\ue4\unrealengine\engine\source\runtime\core\public\UObject/NameTypes.h(522): note: see declaration of 'FName'
xxx.h(40): error C2275: 'FString': illegal use of this type as an expression
x:\ue4\unrealengine\engine\source\runtime\core\public\GenericPlatform/GenericPlatformSplash.h(34): note: see declaration of 'FString'
xxx.h(40): error C2065: 'Z_Param_Test': undeclared identifier
xxx.h(40): error C3861: 'P_GET_TMAP': identifier not found

If I remove UFUNCTION() the function is okay, but what I am trying to do involves TMap.

Addition from (i also added full log above):

TMap cause different error

xxx.h(40): error C2059: syntax error: ','
xxx.h(40): error C2065: 'Z_Param_Test': undeclared identifier
xxx.h(40): error C2059: syntax error: ','
xxx.h(40): error C2065: 'Z_Param_Test': undeclared identifier

TSet argument (in this example TSet) also causes error

 xxx.h(40): error C2059: syntax error: ','
 xxx.h(40): error C2065: 'Z_Param_Test': undeclared identifier
 xxx.h(40): error C2065: 'Z_Param_Test': undeclared identifier

Just to shoot in a little addendum: We’re running version 4.15, which explicitly adds TMap support to blueprints. I can use TMap in blueprints, and have blueprint only functions that use TMaps as input, but I appear unable to create a C++ UFUNCTION that allows a TMap as an argument.

While I found some suggestions that the issue was related to template functions in general, TArray appears to work perfectly fine.

Yes I noticed that my answer was wrong so I deleted it.

Yeah, that happens. :slight_smile: Thanks for the help all the same.

I was able to reproduce it, I also tried different types UObject* with int32 and got different errors

xxx.h(40): error C2059: syntax error: ','
xxx.h(40): error C2065: 'Z_Param_Test': undeclared identifier
xxx.h(40): error C2059: syntax error: ','
xxx.h(40): error C2065: 'Z_Param_Test': undeclared identifier

I also tested TSet and it has exact same issue

xxx.h(40): error C2059: syntax error: ','
xxx.h(40): error C2065: 'Z_Param_Test': undeclared identifier
xxx.h(40): error C2065: 'Z_Param_Test': undeclared identifier

I will include full error logs and my findings (i hope you don’t mind ;p) to the quastion and move this to Bug Raports

Oh, so that’s what happened! I thought “huh, this question thread is remarkably similar to mine”, then I clicked in and it was me… :smiley:

Thanks for the feedback though. Much appreciated.

Hey, I’ve been wondering the same question and I still don’t know how to solve it. I have been looking through the blueprints TMap functions’ code to see how does Epic Games manage the TMap functions’ internally. Then I tried to copy these functions in a custom code but the error still appears.

This is how the Add function looks like:

  1. UFUNCTION(BlueprintCallable, CustomThunk, meta=(DisplayName = “Add”, CompactNodeTitle = “ADD”, MapParam = “TargetMap”, MapKeyParam = “Key”, MapValueParam = “Value”, AutoCreateRefTerm = “Key, Value”), Category = “Utilities|Map”)
  2. static bool Map_Add(const TMap<int32, int32>& TargetMap, const int32& Key, const int32& Value);
    

I wish this helps you.

I am havinf the same results with a type function

`UFUNCTION()

TMap<int32, AActor*> SortMapByKeyValue (TMap<int32, AActor*> MapToSort, bool bDoSortIncrementing);`

Hello, I’m seeing the same issues and currently looking into it. This is likely a bug and will require source code changes for a fix so I’ll keep you posted.

Thank you for reporting this issue. I’ve placed in a bug report for this issue as it seems that functions aren’t been generated correctly, as there are things missing from the .generated.h files for any classes that this is declared in. You can find/track the bug report here: UE-42521

It seems unnecessary to someone else’s thread as resolved when there is still no solution to the problem.

I’m marking it as resolved as there is nothing else to do with this post until the bug has been fixed. This is our standard practice and it’s for tracking reasons.

Have a nice day!

I had a bit of a bash at the problem because I wanted to see if I could make a bypass solution. Unfortunately, my wit didn’t last that long, but I did notice something.

Most of the function calls relating to TMaps in blueprints do not use a general implementation for handling TMaps. Instead, each function call that receives a TMap as a parameter has a CustomThunk that handles the individual map.

The CustomThunks were interesting, but my attempts to use CustomThunk were somewhat stonewalled by my lack of understanding of the underlying systems.

I just stumbled onto this and can’t even believe this is a bug. You know what, with some of the laziness I’ve seen before this doesn’t actually surprise me.

You’re telling me a huge update was released in 4.15 to add TMap and TSet support to blueprints, but not a single person on the development team tested it in C++ with the UFUNCTION macro? It quite literally doesn’t even work at all, I mean the person who made it never even tested it.

I think I’m going to write an email to someone somewhere at Epic because I strongly feel someone should lose their job over this. I mean this is beyond ridiculous, there was a huge section in the 4.15 update highlighting this feature, and it doesn’t even work.

Hello spidershift,

If you would like to provide feedback about these features, please feel free to post in the feedback section of the Unreal Engine forums. This is the primary place to post feedback with the most visibility.

Thanks for your reply but I’m not interested in providing feedback on this feature, especially in some random forum where nobody of actual importance at Epic would see it. However what I have done is reached out directly to Epic through their corporate contact information as I find this unacceptable. If developers aren’t held accountable then things like this happen.

I’m also going to comb through LinkedIn and try out a few other forms of contact so that I can reach the right people at Epic, because nothing does a better job of getting lazy developers in trouble than complaining over and over to their boss.

Hey there! I would highly recommend using the feedback section of the forums as a means to communicate with us at Epic. Actually, the developers who implemented that feature are very active on that section and I also take posts out of there to make reports. Their bosses read those reports and often post in that section as well. The CEO even pops in every now and then to say hi and see how feels about the engine.

Anything posted outside of our forums/answerhub isn’t necessarily going to get a response. It may even just end up getting you blocked from their personal accounts.

Threats, doxing and wild accusations doesn’t get you anywhere but potentially jailtime, spidershift.

I do not see the relevance. Please explain?

Map and Set as local variable(and as parameter I guess) don’t work properly.