What's needed for using C++17

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?

1 Like

I’ve got this issue too, would love some kind of input, comments, thoughts or prayers.

As usual spent 2h for discovery of something which just may as well be written to begin with. So UE 4.22 + VS2019:

Edit the $project\Source$project$project.Build.cs file

PCHUsage = PCHUsageMode.NoSharedPCHs;
PrivatePCHHeaderFile = "$pch.h";
CppStandard = CppStandardVersion.Cpp17;

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.

Good luck with the rest!


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)
  • Add


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:

PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
CppStandard = CppStandardVersion.Latest;

1 Like

Thanks a lot. I just build the project and encountered lots warning and error in UE headers. But after applying these I still get some erros.

This worked for me with UE_4.27 and c++17, now I can nativize Blueprint assets on packaging - before I did this it always failed because of C++17 standard needed error.

thank you for help

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.

Best of luck.

1 Like

Thanks king

For anyone that finds this in the future, and doesn’t know how to read the Build Configuration link this is an example:
BuildConfiguration is the section that holds the first set of variable options before the UEBuildConfiguration section. (I didn’t realize it was a section and tried to put <CppStandard>Cpp17</CppStandard> in the <Configuration …></Configuration> section)

However, I still have intellisense “errors” where it will compile and work correctly but will give me red underlines at code that it thinks is wrong. I have tried including the CppStandard = CppStandardVersion.Cpp17; in my build.cs and then regenerating the solution file from right clicking the .uproject file and selecting the “Refresh Visual Studio Project”.

I guess it’s just one of those errors to ignore, but if anyone finds a way of updating intellisense from using c++14 to c++17 let me know.