Download

Strange compilation behavior with interfaces

It seems whenever I change something that involves and interface, I need to compile twice. First time I get an unresolved externals error, second time goes through fine. Does anyone else experience this?

While I’m at it, I’m also a bit confused why it makes no difference if I mark the implementing method “override” or not. Is that normal? I’ve used the “= 0” behind the method in the interface to make it pure virtual as also described here: [Question] C++ Interfaces? - UE4 AnswerHub

Last but not least, in the UT code I found that they’re using interfaces differently. Take for example UTResetInterface.h



// implement this interface for Actors that should handle game mode resets (halftime in CTF, role swap in Assault, etc)
// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#pragma once

#include "UTResetInterface.generated.h"

UINTERFACE(MinimalAPI)
class UUTResetInterface : public UInterface
{
	GENERATED_UINTERFACE_BODY()
};

class UNREALTOURNAMENT_API IUTResetInterface
{
	GENERATED_IINTERFACE_BODY()

	UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = Game)
	void Reset();
};


which they then implement by including the constructor in UTGameMode.cpp like so:



UUTResetInterface::UUTResetInterface(const FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{}

...

AUTGameMode::AUTGameMode(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
...
}


Note also how they use UUTResetInterface and not IUTResetInterface in this case. Why do they do it like this?