Turn off Shadowed Variable Errors

I am trying to turn off the new build settings for UE 4.25:

Using backward-compatible build settings. The latest version of UE4 sets the following values by default, which may require code changes:

ShadowVariableWarningLevel = WarningLevel.Error => Treats shadowed variable warnings as errors. (Previously: WarningLevel.Warning).

Suppress this message by setting ‘DefaultBuildSettings = BuildSettingsVersion.V2;’ in UE4_FeaturesEdit.Target.cs, and explicitly overriding settings that differ from the new defaults.

I suppressed the message by adding that line and then set “ShadowVariableWarningLevel = WarningLevel.Off” within my Target.cs file. Nothing changes and I still get an error for shadowed variables. I don’t get the idea behind this, why is shadowing variables an error? It allows me to rename my function parameters to sensible names instead of things like InItems, InSkills, etc.
How do I turn this setting off?

Bump bump bump

Shadow Variables are a problem because it’s unclear what variable you are interacting with in the function body. It’s better to just give you function inputs variable names that don’t clash.

It might even be that compilers might treat things differently. I’m unware of how to turn if off, but I’m pretty sure you can’t turn this off without changing/recompiling the engine anyway.

Isn’t that kind of unnecessary? The keyword this exists in all modern C-type languages, which solves this “problem”. Shadow variables are allowed in all the languages that I know of and use, and not once have I ran into any problem with them.

If it is not possible to change this, I would like to ask what is the best way to name function parameters that are to be assigned to class member variables. For example, should:

MyClass(TArray<Skill> Skills) {
    this->Skills = Skills;


MyClass(TArray<Skill> InSkills) {
    Skills = InSkills;


Agree. Shadowing Variables is a non-problem in all other programming languages.

Raising an error when a variable is shadowing is simply trying to solve a problem where none exists.

m.duman made excellent points. Shadowing in c++ is a feature not a bug and ‘this’ keyword already handles name collisions for you.

Greetings @josephjaspers !

We see that this is your first time posting in our forums! :medal_sports: We welcome you to the Unreal Engine Community with open virtual arms! Thank you so much for your contribution to this thread. It is members like you that keep our forums going strong! :muscle:t4:

There are macros for this (although they may be defined empty on certain platforms/compilers)
PRAGMA_DISABLE_SHADOW_VARIABLE_WARNINGS and PRAGMA_ENABLE_SHADOW_VARIABLE_WARNINGS. Additionally each *.Build.cs File can set ShadowVariableWarningLevel on the ModuleRules which can be set to either Off, Warning or Error.


Clang doesn’t like the shadow variables and will fail compilation. Clang is usually used when compiling non-microsoft hardware, like Playstation. I’m not sure if you can configure clang to ignore shadow variables and still be compatible though.