bOptimizeCode = true not being recognized in UE 4.26

Hi Folks,

I was trying to add optimization flags to build my project. I came across this boolean bOptimizeCode in

However, when I add bOptimizeCode = true as part of my project’s .Build.cs or plugin’s .Build.cs files, I get the error - “error CS0103: The name ‘bOptimizeCode’ does not exist in the current context. UnrealBuildTool : error : Unable to compile source files.”

I don’t understand. The boolean is clearly being defined in the VCToolChain.cs source file, which means it must be valid. Any ideas/suggestions on what might be wrong here?

I tried on Windows and Mac, didn’t work on both.

Happy New year! and Cheers!

You want OptimizeCode = CodeOptimization.Always. The flag you’re looking at isn’t part of ModuleRules, which is what the build.cs files define for modules.

Thanks @alistairwick. That makes sense. In that case how do I track what optimization flags OptimizeCode = CodeOptimization.Always adds to the compilation process?

I think I found it. OptimizeCode variable from ModuleRules.cs is used here ( to get CompileEnvironment variable bOptimizeCode. And bOptimizeCode is used to decide the optimization flags based on platform here - .