Description

Paired types (e.g. TMap) in a delegate signature do not compile after nativizing a Blueprint class containing it due to the macro expansion and comma inside the template spec between key and value types.

In "regular" native C++ code the suggested solution is to use a typedef (https://answers.unrealengine.com/questions/600369/declare-delegate-oneparam-makes-compile-error-on-p.html).

However in nativized Blueprint code, we will need to autogenerate a typedef to work around it.

One way to work around it for now is to manually modify the generated source after cooking to replace the signature and use a typedef that's added manually after the fact, but that's not ideal since most projects utilize the UAT BuildCookRun pipeline or a command that does.

Steps to Reproduce
  1. Create a new (blank) UE4 BP-only project.
  2. Add a new Blueprint class (MyEventManager).
  3. Open it in the Blueprint editor and add a new Event Dispatcher (MyTestEvent).
  4. With the new Event Dispatcher selected in the My Blueprints tab, add a new input in the Details tab (MyTestInput).
  5. Change the input type to 'String', then click the icon to the right of the name box to expand the drop-down and choose 'Map'.
  6. Change the key type on the map to 'Integer'.
  7. Compile and save, then close the Blueprint editor.
  8. Create another new Blueprint class (MyBlueprint).
  9. Open it in the Blueprint editor and add a new object reference variable of type 'MyEventManager' (NewVar_0).
  10. Drag the new variable into the Event Graph window and choose 'Get'.
  11. Drag off the 'Get' node and add a call to 'MyTestEvent'.
  12. Wire a 'Make Map' node up to the 'MyTestInput' pin.
  13. Wire the 'MyTestEvent' call to the 'BeginPlay' event node.
  14. Compile and save, then close the Blueprint editor.
  15. Choose Edit->Project Settings, then change Packaging/Blueprint Nativization Method to 'Inclusive'.
  16. Choose File->Package Project->Windows->Win64 and select a folder location. Wait for packaging to finish.
  17. Note that a compile error will result:
    UATHelper: Packaging (Windows (64-bit)): D:\dev\local\Projects\NatDelegateTest\Intermediate\Plugins\NativizedAssets\Windows\Game\Source\NativizedAssets\Public\MyEventManager__pf1010915279.h(12): error C4002: too many actual parameters for macro 'DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam'
    UATHelper: Packaging (Windows (64-bit)): D:\dev\local\Projects\NatDelegateTest\Intermediate\Plugins\NativizedAssets\Windows\Game\Source\NativizedAssets\Public\MyEventManager__pf1010915279.h(12): error C2976: 'TMap': too few template arguments
    UATHelper: Packaging (Windows (64-bit)): D:\dev\UE4\Dev-Framework\Engine\Source\Runtime\Core\Public\Templates/SharedPointerTesting.inl(11): note: see declaration of 'TMap'
Callstack

N/A

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-59140 in the post.

3
Login to Vote

Won't Fix
ComponentUE - Gameplay - Blueprint
Affects Versions4.194.20
CreatedMay 15, 2018
ResolvedJul 15, 2021
UpdatedJul 19, 2021