Hi there. I’m attempting to try out (on Windows) the new C++17 support that’s described in the 4.22 release notes, and I’m having a bit of difficulty.
First of all I tried adding CppStandard = CppStandardVersion.Cpp17; to my test project (named “QuickStart”) QuickStartEditor.Target.cs file and hitting compile in the editor.
That gives an error:
Adding that *BuildEnvironment *option to QuickStartEditor.Target.cs gives errors about missing header files, so I assume that’s not the right approach:
I tried building the editor from source with *CppStandard *set to Cpp17 and that gave some errors in the third-party code that suggested to me that the editor isn’t meant to be built in C++17 mode yet. I successfully built the editor without setting CppStandard, but then when I compiled my project using that editor it took a long time (I presume it was building the whole engine source again) and then failed with linking errors. (Sorry I didn’t make a note of the error messages for these steps, and annoyingly I can’t remember which settings I had in the .Target.cs file.)
So I’m not sure what the correct way of using C++17 is. Has anyone got it to work yet?
Where $project and $pch should be substituted with something to match your application. Technically, the custom PCH is not needed but since UE 4.21 the UE build tool wants it. Of course, this file must be created if it does not exist and can be filled in with whatever headers make sense.
Another annoyance is IntelliSense which wont get that the project is based on C++17 so I digged out the idea that you can go to Project Properties -> NMake -> Additional Options and add /std:c++17
This whole thing allowed me to use c++17 language features and part of the STL, I havent tried yet any runtime dependecies like using new (incl. vector, thread) and stuff.
If you modify the UnrealBuildTool, you can also use the PCH. I ran into the same issue with c++20 now (September 2020), and this is obviously a horrible hackish way to do it, but since I spent 3 hours R&Ding it, I might as well post it here:
Open the VS project UE_4.25\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.csproj
Depending on which .NET SDK is intalled on your machine, you might need to change the target framework
Find the file Platform\Windows\VCToolChain.cs in that solution
Go to the end of the method AppendCLArguments_Global (it’s around line 537 at the time of writing)
there, or whatever c++ standard you want the compiler to use
build the solution. It should build to UE_4.25\Engine\Binaries\DotNET\UnrealBuildTool.exe
Now build your game project with the build settings set to:
sorry to answer this late on this post, but here some retroengineering I did back in my days would have been helpful to you.
You can build the engine with any configuration you wish for without changing the UBT source code (included modifying the c++ version) by modifying the [YourEnginePath]/Engine/Saved/UnrealBuildTool/BuildConfiguration.xml
for details, see the documentation here :
as well as the schema file inside the same folder that lists all possible values.
I leave my answer for anyone that would look for the same solution.