Log issue (passing a FString)


my turn to play a bit with the Log function (I must admit is a bit a pain to use it) and I’m unable to compile for a reason that I don’t understand unfortunately. Here is my code :

void elog(const FString& msg)
	UE_LOG(LogEXIL, Log, TEXT("___ TEST EXIL ___ "));

        UE_LOG(LogEXIL, Log, TEXT("___ %s ____ "), msg);

The first UE_LOG will compile while the second one will make an error :

3>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""C:\UDK\Rocket\Engine\Binaries\DotNET\RocketUnrealBuildTool.exe" EXILUncooked Win64 Development "C:\UDK\Rocket\Projects\EXIL\EXIL.uproject" -rocket" exited with code 1.
2>  Module.EXIL.cpp
2>C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(404): error C2665: 'CheckVA' : none of the 11 overloads could convert all the argument types
2>          C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(71): could be 'uint32 CheckVA(uint32)'
2>          C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(72): or       'uint8 CheckVA(uint8)'
2>          C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(73): or       'int32 CheckVA(int32)'
2>          C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(74): or       'uint64 CheckVA(uint64)'
2>          C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(75): or       'int64 CheckVA(int64)'
2>          C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(76): or       'double CheckVA(double)'
2>          C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(77): or       'long CheckVA(long)'
2>          C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(78): or       'long CheckVA(unsigned long)'
2>          C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(79): or       'TCHAR CheckVA(TCHAR)'
2>          C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(80): or       'void *CheckVA(ANSICHAR *)'
2>          C:\UDK\Rocket\Engine\Source\Runtime\Core\Public\Misc\OutputDevice.h(81): or       'bool CheckVA(bool)'
2>          while trying to match the argument list '(FString)'
2>          C:\UDK\Rocket\Projects\EXIL\Source\EXIL\Private\EXIL.cpp(18) : see reference to function template instantiation 'void FMsg::Logf(const ANSICHAR *,int32,const FName &,ELogVerbosity::Type,const TCHAR *,T1)' being compiled
2>          with
2>          [
2>              T1=FString
2>          ]
2>  -------- End Detailed Actions Stats -----------------------------------------------------------

%s does not accept FString; it is a character pointer; use:

UE_LOG(LogEXIL, Log, TEXT("___ %s ____ "), *msg);

Haa, thanks for the quick answer ! It’s working now ! :slight_smile: