This documentation is archived and is not being maintained.

Compiler Warning (level 1) C4270

Visual Studio .NET 2003

nonstandard extension used: 'initializing': a non-const 'type1' must be initialized with an l-value, not a function returning 'type2'

A nonconst reference must be initialized with an l-value, making the reference a name for that l-value. A function call is an l-value only if the return type is a reference. Under Microsoft extensions to the C++ language, treat any function call as an l-value for the purpose of initializing references. If Microsoft extensions are disabled (/Za), an error occurs.

To avoid this warning

  • Make the reference a const reference. If the reference is const and the function return type is not compatible with the type of the reference, the compiler generates and initializes a temporary variable (which is inefficient), or
  • Use the following pragma:
    #pragma warning(disable:4270)