/Zc:auto (Deduce Variable Type)
This page is specific to:.NET Framework Version:4.0
Visual Studio 2010 - Visual C++
/Zc:auto (Deduce Variable Type)

The /Zc:auto[-] compiler option tells the compiler how to use the auto keyword to declare variables. If you specify the default option, /Zc:auto, the compiler deduces the type of the declared variable from its initialization expression. If you specify /Zc:auto-, the compiler allocates the variable to the automatic storage class.

/Zc:auto[-]
Remarks

The C++ standard defines an original and a revised meaning for the auto keyword. Before Visual C++ 2010, the keyword declares a variable in the automatic storage class; that is, a variable that has a local lifetime. Starting with Visual C++ 2010, the keyword deduces the type of a variable from the declaration's initialization expression. Use the /Zc:auto[-] compiler option to tell the compiler to use the original or revised meaning of the auto keyword.

The compiler issues an appropriate diagnostic message if your use of the auto keyword contradicts the current compiler option. For more information, see auto Keyword. For more information about conformance issues with Visual C++, see Compatibility and Compliance Issues in Visual C++.

To set this compiler option in Visual Studio

  1. Open the project's Property Pages dialog box. For details, see Modifying Project Settings.

  2. Click the Configuration Properties node.

  3. Click the C/C++ node.

  4. Click the Command Line node.

  5. Add /Zc:auto or /Zc:auto- to the Additional options: pane.

See Also

Reference

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View