Description

Using UFUNCTION(Server, Reliable, WithValidation) with an RPC function results in a failed build in Visual Studio.

The same test in Main yields a different set of error messages.

Steps to Reproduce
  1. Create a new code project using the First Person template, no starter content.
  2. In the .h file for the project, add a #include "Engine.h" line.
  3. In the .h file for the character class, add the following code under a public: access specifier:
    UFUNCTION(Server, Reliable, WithValidation)
    void ServerTestMessage();
    
  4. In the .cpp file for the project's character class, add the following code, filling in the class name as needed:
    void /*ClassName*/::ServerTestMessage()
    {
    	if (Role < ROLE_Authority)
    	{
    		if (GEngine)
    		{
    			GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("Greetings from the ServerTestMessage function."));
    		}
    		ServerTestMessage();
    	}
    }
    
    bool /*ClassName*/::ServerTestMessage_Validate()
    {
    	return true;
    }
    
    void /*ClassName*/::ServerTestMessage_Implementation()
    {
    	ServerTestMessage();
    }
    
  5. Add the line bReplicates = true; to the constructor for the character class.
  6. Build the project in Visual Studio.

RESULT:
The build fails with the following errors:

1>TestMulticast2.generated.cpp.obj : error LNK2005: "public: void __cdecl ATestMulticast2Character::ServerTestMessage(void)" (?ServerTestMessage@ATestMulticast2Character@@QEAAXXZ) already defined in TestMulticast2Character.cpp.obj
1>C:\Users\Tim.Lincoln\Documents\Unreal Projects\TestMulticast2\Binaries\Win64\UE4Editor-TestMulticast2.dll : fatal error LNK1169: one or more multiply defined symbols found

EXPECTED:
The build completes successfully.

Have Comments or More Details?

Head over to the existing AnswerHub thread and let us know what's up.

0
Login to Vote

By Design
ComponentNetworking
Affects Versions4.7.3
Target Fix4.8
CreatedApr 1, 2015
ResolvedApr 7, 2015
UpdatedApr 27, 2018