When compiling C++ I get engine error

Hey Guys,

I am trying to upgrade my project from 5.3.2 to 5.4.1 but I am getting an error from engine source files when trying to compile C++ code.

This is the error message I am getting:
UE_5.4\Engine\Source\Runtime\Core\Public\String\FormatStringSan.h(99): error C2338: static_assert failed: ‘’%s’ expects TCHAR*; use ‘%hs’ for const char*.’

I hope somebody could help me.

Kind regards
Maurice

1 Like

Show the whole log, this error is probably caused by something in your code.

you probably need to deference a pointer or something, but no one can help you but yourself with the info you shared

1 Like

Ah of course. I already looked through it but could not find any other Problem with my limited experience.

Thank you for your reply

1>--------------------Project: Default-------------------------------------------
1>[1/17] Link [x64] UnrealEditor-SpeechToLife.lib (0:00.09 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Plugins\SpeechToLife\Intermediate\Build\Win64\x64\UnrealEditor\Development\SpeechToLife\UnrealEditor-SpeechToLife.lib" und Objekt "C:\Users\username\Desktop\repos\project\Plugins\SpeechToLife\Intermediate\Build\Win64\x64\UnrealEditor\Development\SpeechToLife\UnrealEditor-SpeechToLife.exp" werden erstellt.
1>[2/17] Link [x64] UnrealEditor-projectEditor.lib (0:00.10 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Intermediate\Build\Win64\x64\UnrealEditor\Development\projectEditor\UnrealEditor-projectEditor.lib" und Objekt "C:\Users\username\Desktop\repos\project\Intermediate\Build\Win64\x64\UnrealEditor\Development\projectEditor\UnrealEditor-projectEditor.exp" werden erstellt.
1>[3/17] Link [x64] UnrealEditor-projectProj.lib (0:00.10 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Intermediate\Build\Win64\x64\UnrealEditor\Development\projectProj\UnrealEditor-projectProj.lib" und Objekt "C:\Users\username\Desktop\repos\project\Intermediate\Build\Win64\x64\UnrealEditor\Development\projectProj\UnrealEditor-projectProj.exp" werden erstellt.
1>[4/17] Link [x64] UnrealEditor-KantanChartsEditor.lib (0:00.17 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Plugins\KantanCharts\Intermediate\Build\Win64\x64\UnrealEditor\Development\KantanChartsEditor\UnrealEditor-KantanChartsEditor.lib" und Objekt "C:\Users\username\Desktop\repos\project\Plugins\KantanCharts\Intermediate\Build\Win64\x64\UnrealEditor\Development\KantanChartsEditor\UnrealEditor-KantanChartsEditor.exp" werden erstellt.
1>[5/17] Link [x64] UnrealEditor-SpeechToLifeVosk.lib (0:00.15 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Plugins\SpeechToLife\Intermediate\Build\Win64\x64\UnrealEditor\Development\SpeechToLifeVosk\UnrealEditor-SpeechToLifeVosk.lib" und Objekt "C:\Users\username\Desktop\repos\project\Plugins\SpeechToLife\Intermediate\Build\Win64\x64\UnrealEditor\Development\SpeechToLifeVosk\UnrealEditor-SpeechToLifeVosk.exp" werden erstellt.
1>[6/17] Link [x64] UnrealEditor-UltraleapTrackingEditor.lib (0:00.14 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Plugins\UltraleapTracking\Intermediate\Build\Win64\x64\UnrealEditor\Development\UltraleapTrackingEditor\UnrealEditor-UltraleapTrackingEditor.lib" und Objekt "C:\Users\username\Desktop\repos\project\Plugins\UltraleapTracking\Intermediate\Build\Win64\x64\UnrealEditor\Development\UltraleapTrackingEditor\UnrealEditor-UltraleapTrackingEditor.exp" werden erstellt.
1>[7/17] Link [x64] UnrealEditor-SpeechToLifeVosk.dll (0:01.07 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Plugins\SpeechToLife\Intermediate\Build\Win64\x64\UnrealEditor\Development\SpeechToLifeVosk\UnrealEditor-SpeechToLifeVosk.sup.lib" und Objekt "C:\Users\username\Desktop\repos\project\Plugins\SpeechToLife\Intermediate\Build\Win64\x64\UnrealEditor\Development\SpeechToLifeVosk\UnrealEditor-SpeechToLifeVosk.sup.exp" werden erstellt.
1>[8/17] Link [x64] UnrealEditor-SpeechToLifeEditor.dll (0:01.09 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Plugins\SpeechToLife\Intermediate\Build\Win64\x64\UnrealEditor\Development\SpeechToLifeEditor\UnrealEditor-SpeechToLifeEditor.sup.lib" und Objekt "C:\Users\username\Desktop\repos\project\Plugins\SpeechToLife\Intermediate\Build\Win64\x64\UnrealEditor\Development\SpeechToLifeEditor\UnrealEditor-SpeechToLifeEditor.sup.exp" werden erstellt.
1>[9/17] Link [x64] UnrealEditor-SpeechToLife.dll (0:01.15 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Plugins\SpeechToLife\Intermediate\Build\Win64\x64\UnrealEditor\Development\SpeechToLife\UnrealEditor-SpeechToLife.sup.lib" und Objekt "C:\Users\username\Desktop\repos\project\Plugins\SpeechToLife\Intermediate\Build\Win64\x64\UnrealEditor\Development\SpeechToLife\UnrealEditor-SpeechToLife.sup.exp" werden erstellt.
1>[10/17] Link [x64] UnrealEditor-projectEditor.dll (0:01.06 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Intermediate\Build\Win64\x64\UnrealEditor\Development\projectEditor\UnrealEditor-projectEditor.sup.lib" und Objekt "C:\Users\username\Desktop\repos\project\Intermediate\Build\Win64\x64\UnrealEditor\Development\projectEditor\UnrealEditor-projectEditor.sup.exp" werden erstellt.
1>[11/17] Link [x64] UnrealEditor-KantanChartsEditor.dll (0:01.18 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Plugins\KantanCharts\Intermediate\Build\Win64\x64\UnrealEditor\Development\KantanChartsEditor\UnrealEditor-KantanChartsEditor.sup.lib" und Objekt "C:\Users\username\Desktop\repos\project\Plugins\KantanCharts\Intermediate\Build\Win64\x64\UnrealEditor\Development\KantanChartsEditor\UnrealEditor-KantanChartsEditor.sup.exp" werden erstellt.
1>[12/17] Link [x64] UnrealEditor-projectProj.dll (0:01.20 at +0:00)
1>   Bibliothek "C:\Users\username\Desktop\repos\project\Intermediate\Build\Win64\x64\UnrealEditor\Development\projectProj\UnrealEditor-projectProj.sup.lib" und Objekt "C:\Users\username\Desktop\repos\project\Intermediate\Build\Win64\x64\UnrealEditor\Development\projectProj\UnrealEditor-projectProj.sup.exp" werden erstellt.
1>[13/17] Compile [x64] Module.UltraleapTracking.2.cpp (0:03.12 at +0:00)
1>D:\Epic\UE_5.4\Engine\Source\Runtime\Core\Public\String\FormatStringSan.h(99): error C2338: static_assert failed: ''%s' expects `TCHAR*`; use '%hs' for `const char*`.'
1>D:\Epic\UE_5.4\Engine\Source\Runtime\Core\Public\String\FormatStringSan.h(99): note: der Vorlageninstanziierungskontext (der älteste zuerst) ist
1>C:\Users\username\Desktop\repos\project\Plugins\UltraleapTracking\Source\UltraleapTrackingCore\Private\LeapWrapper.cpp(436): note: Siehe Verweis auf die gerade kompilierte Klasse Vorlage-Instanziierung "UE::Core::Private::FormatStringSan::TPresentErr<1>::TErrMsg<UE::Core::Private::FormatStringSan::TAtArgPos<0>>".
1>
1>Error executing C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64\cl.exe (tool returned code: 2)
1>---------------------- Done ----------------------
1>
1>    Rebuild All: 0 succeeded, 1 failed, 0 skipped
1>
1>1 build system warning(s):
1>   - License not activated
1>
1>Total time in XGE executor: 3.46 seconds
1>Total execution time: 5.09 seconds
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(44,5): error MSB3073: Der Befehl "D:\Epic\UE_5.4\Engine\Build\BatchFiles\Build.bat projectEditor Win64 Development -Project="C:\Users\username\Desktop\repos\project\projectProj.uproject" -WaitMutex -FromMsBuild -architecture=x64" wurde mit dem Code 6 beendet.
1>Die Erstellung des Projekts "projectProj.vcxproj" ist abgeschlossen -- FEHLER.
========== Build: 0 erfolgreich, 1 Fehler, 11 aktuell, 0 übersprungen ==========
========== Erstellen abgeschlossen um 13:43 und dauerte 06,292 Sekunden ==========

What do you have here?
C:\Users\username\Desktop\repos\project\Plugins\UltraleapTracking\Source\UltraleapTrackingCore\Private\LeapWrapper.cpp(436)
In line 436

I often encounter a similar error when using UE_LOG and mistakenly omitting the asterisk (*) before an FString. For instance, I’ve run into issues like so:

FString Text = TEXT("Hello");
UE_LOG(LogTemp, Warning, TEXT("%s"), Text);

This results in an error because UE_LOG expects a const TCHAR* type for string formatting, but Text is an FString. The correct way to pass FString to UE_LOG is by using the * operator to convert FString to const TCHAR*, like so:

UE_LOG(LogTemp, Warning, TEXT("%s"), *Text);

Adding the asterisk before Text correctly formats the string and may be a solution similar to the one you are looking for.

Thanks a lot. That helped. I just had to switch the UE_LOG(“%s”) to UE_LOG(“%hs”) at two points in the LeapWrapper and know I get other errors but I can look into those myself.

1 Like

Thanks for the Hint i just need to carefully read the log next time

Thank you. This was the solution for me.