FORCEINLINE causing linker errors? (Possible bug?)

Hey guys,

Recently I decided to ask a friend to help and test the build of my game.
So I gone ahead, and in VS2013 I switched from “DebugGame Editor” to “DebugGame”.
When I tried to build, I got this:


1>MyGameMode.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl AMyPlayerState::ScoreKill(class AMyPlayerState *,int)" (?ScoreKill@AMyPlayerState@@QEAAXPEAV1@H@Z) referenced in function "public: virtual void __cdecl AMyGameMode::Killed(class AController *,class AController *,class APawn *,class UDamageType const *)" (?Killed@AMyGameMode@@UEAAXPEAVAController@@0PEAVAPawn@@PEBVUDamageType@@@Z)
1>MyGameMode.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl AMyPlayerState::ScoreDeath(class AMyPlayerState *,int)" (?ScoreDeath@AMyPlayerState@@QEAAXPEAV1@H@Z) referenced in function "public: virtual void __cdecl AMyGameMode::Killed(class AController *,class AController *,class APawn *,class UDamageType const *)" (?Killed@AMyGameMode@@UEAAXPEAVAController@@0PEAVAPawn@@PEBVUDamageType@@@Z)
1>MyGameMode.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl AMyPlayerState::ScoreFlagCapture(void)" (?ScoreFlagCapture@AMyPlayerState@@QEAAXXZ) referenced in function "public: virtual void __cdecl AMyGameMode::FlagCaptured(class AController *)" (?FlagCaptured@AMyGameMode@@UEAAXPEAVAController@@@Z)
1>MyGameMode.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl AMyPlayerState::SetTeam(enum ETeam)" (?SetTeam@AMyPlayerState@@QEAAXW4ETeam@@@Z) referenced in function "protected: virtual class FString __cdecl AMyGameMode::InitNewPlayer(class APlayerController *,class TSharedPtr<class FUniqueNetId,0> const &,class FString const &,class FString const &)" (?InitNewPlayer@AMyGameMode@@MEAA?AVFString@@PEAVAPlayerController@@AEBV?$TSharedPtr@VFUniqueNetId@@$0A@@@AEBV2@2@Z)
1>MyPlayerController.cpp.obj : error LNK2001: unresolved external symbol "public: void __cdecl AMyPlayerState::SetTeam(enum ETeam)" (?SetTeam@AMyPlayerState@@QEAAXW4ETeam@@@Z)
1>MyPlayerController.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl AMyPlayerState::SetPlayerClass(enum EClass)" (?SetPlayerClass@AMyPlayerState@@QEAAXW4EClass@@@Z) referenced in function "public: void __cdecl AMyPlayerController::ChangePlayerClass(enum EClass,bool,bool)" (?ChangePlayerClass@AMyPlayerController@@QEAAXW4EClass@@_N1@Z)


So, I inspected my code and I have this:

	FORCEINLINE void ScoreKill(AMyPlayerState* Victim, int32 Points);

	FORCEINLINE void ScoreDeath(AMyPlayerState* KilledBy, int32 Points);

	FORCEINLINE void ScoreFlagCapture();

	FORCEINLINE void ScorePoints(int32 Points);

	FORCEINLINE void SetTeam(ETeam NewTeam);

	FORCEINLINE void SetPlayerClass(EClass NewPlayerClass);

As soon as I gone ahead and removed all the FORCEINLINE function modifier, it works again… But all of these are supposed to be inline.

Any idea of what causes this issue, and how to fix it (without making the functions “not-inline”?) ?
(Again, it compiles fine on “DebugGame Editor”, but fails on “DebugGame”.)

Thank you in advance! :slight_smile:

If declaration of inline function is in header file the definition should be there too.

Pierdek is right.

Something also to remember is “A function definition in a class definition is an inline function definition, even without the use of the inline specifier.”

1 Like

I see… So, there’s no way to forward an inline definition…

But… Any idea why does it compile in “DebugGame Editor”, but fails on “DebugGame” ?