Download

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;
}


become:


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

bump bump bump