Compiler Error C3480
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Compiler Error C3480.
var': a lambda capture variable must be from an enclosing function scope
The lambda capture variable is not from an enclosing function scope.
To correct this error
- Remove the variable from the capture list of the lambda expression.
The following example generates C3480 because the variable global is not from an enclosing function scope:
// C3480a.cpp
int global = 0;
int main()
{
[&global] { global = 5; }(); // C3480
}
The following example resolves C3480 by removing the variable global from the capture list of the lambda expression:
// C3480b.cpp
int global = 0;
int main()
{
[] { global = 5; }();
}
Show: