|
1 | 1 | --- |
2 | 2 | title: "-Zc:auto (Deduce Variable Type) | Microsoft Docs" |
3 | 3 | ms.custom: "" |
4 | | -ms.date: "11/04/2016" |
5 | | -ms.reviewer: "" |
6 | | -ms.suite: "" |
| 4 | +ms.date: "02/28/2018" |
7 | 5 | ms.technology: ["cpp-tools"] |
8 | | -ms.tgt_pltfrm: "" |
9 | 6 | ms.topic: "article" |
10 | 7 | f1_keywords: ["/Zc:auto"] |
11 | 8 | dev_langs: ["C++"] |
12 | 9 | helpviewer_keywords: ["-Zc compiler options (C++)", "Deduce variable type (C++)", "/Zc compiler options (C++)", "Zc compiler options (C++)"] |
13 | 10 | ms.assetid: 5f5bc102-44c3-4688-bbe1-080594dcee5c |
14 | | -caps.latest.revision: 9 |
15 | 11 | author: "corob-msft" |
16 | 12 | ms.author: "corob" |
17 | 13 | manager: "ghogen" |
18 | 14 | ms.workload: ["cplusplus"] |
19 | 15 | --- |
20 | 16 | # /Zc:auto (Deduce Variable Type) |
21 | | -The **/Zc:auto[-]** compiler option tells the compiler how to use the [auto keyword](../../cpp/auto-keyword.md) 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. |
22 | | - |
23 | | -## Syntax |
24 | | - |
25 | | -``` |
26 | | -/Zc:auto[-] |
27 | | -``` |
28 | | - |
29 | | -## Remarks |
30 | | - The C++ standard defines an original and a revised meaning for the `auto` keyword. Before [!INCLUDE[cpp_dev10_long](../../build/includes/cpp_dev10_long_md.md)], the keyword declares a variable in the automatic storage class; that is, a variable that has a local lifetime. Starting with [!INCLUDE[cpp_dev10_long](../../build/includes/cpp_dev10_long_md.md)], 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. |
31 | | - |
32 | | - 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](../../cpp/auto-keyword.md). For more information about conformance issues with Visual C++, see [Nonstandard Behavior](../../cpp/nonstandard-behavior.md). |
33 | | - |
34 | | -### To set this compiler option in Visual Studio |
35 | | - |
36 | | -1. Open the project's **Property Pages** dialog box. For details, see [Working with Project Properties](../../ide/working-with-project-properties.md). |
37 | | - |
38 | | -2. Click the **Configuration Properties** node. |
39 | | - |
40 | | -3. Click the **C/C++** node. |
41 | | - |
42 | | -4. Click the **Command Line** node. |
43 | | - |
44 | | -5. Add **/Zc:auto** or **/Zc:auto-** to the **Additional options:** pane. |
45 | | - |
46 | | -## See Also |
47 | | - [/Zc (Conformance)](../../build/reference/zc-conformance.md) |
48 | | - [auto Keyword](../../cpp/auto-keyword.md) |
| 17 | + |
| 18 | +The **/Zc:auto[-]** compiler option tells the compiler how to use the [auto keyword](../../cpp/auto-keyword.md) 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. |
| 19 | + |
| 20 | +## Syntax |
| 21 | + |
| 22 | +> **/Zc:auto**[**-**] |
| 23 | +
|
| 24 | +## Remarks |
| 25 | + |
| 26 | +The C++ standard defines an original and a revised meaning for the `auto` keyword. Before [!INCLUDE[cpp_dev10_long](../../build/includes/cpp_dev10_long_md.md)], the keyword declares a variable in the automatic storage class; that is, a variable that has a local lifetime. Starting with [!INCLUDE[cpp_dev10_long](../../build/includes/cpp_dev10_long_md.md)], 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 **/Zc:auto** option is on by default. The [/permissive-](permissive-standards-conformance.md) option does not change the default setting of **/Zc:auto**. |
| 27 | + |
| 28 | +The compiler issues an appropriate diagnostic message if your use of the `auto` keyword contradicts the current **/Zc:auto** compiler option. For more information, see [auto Keyword](../../cpp/auto-keyword.md). For more information about conformance issues with Visual C++, see [Nonstandard Behavior](../../cpp/nonstandard-behavior.md). |
| 29 | + |
| 30 | +### To set this compiler option in Visual Studio |
| 31 | + |
| 32 | +1. Open the project's **Property Pages** dialog box. For details, see [Working with Project Properties](../../ide/working-with-project-properties.md). |
| 33 | + |
| 34 | +1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page. |
| 35 | + |
| 36 | +1. Add **/Zc:auto** or **/Zc:auto-** to the **Additional options:** pane. |
| 37 | + |
| 38 | +## See also |
| 39 | + |
| 40 | +[/Zc (Conformance)](../../build/reference/zc-conformance.md)<br/> |
| 41 | +[auto Keyword](../../cpp/auto-keyword.md) |
0 commit comments