Skip to content

Latest commit

 

History

History
29 lines (19 loc) · 1.28 KB

File metadata and controls

29 lines (19 loc) · 1.28 KB
title auto Keyword
ms.date 05/07/2019
ms.assetid 744a41c0-2510-4140-a1be-96257e722908

auto Keyword

The auto keyword is a declaration specifier. However, the C++ standard defines an original and a revised meaning for this keyword. Before Visual Studio 2010, the auto keyword declares a variable in the automatic storage class; that is, a variable that has a local lifetime. Starting with Visual Studio 2010, the auto keyword declares a variable whose type is deduced from the initialization expression in its declaration. The /Zc:auto[-] compiler option controls the meaning of the auto keyword.

Syntax

auto declarator ;
auto declarator initializer;

Remarks

The definition of the auto keyword changes in the C++ programming language, but not in the C programming language.

The following topics describe the auto keyword and the corresponding compiler option:

  • auto describes the new definition of the auto keyword.

  • /Zc:auto (Deduce Variable Type) describes the compiler option that tells the compiler which definition of the auto keyword to use.

See also

Keywords