Skip to content

Commit 8926252

Browse files
author
Michael Blome
committed
register keyword removed
1 parent f51a1f0 commit 8926252

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

‎docs/cpp/storage-classes-cpp.md‎

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ A *storage class* in the context of C++ variable declarations is a type specifie
4343

4444
1. The [mutable](../cpp/mutable-data-members-cpp.md) keyword may be considered a storage class specifier. However, it is only available in the member list of a class definition.
4545

46-
2. Starting with Visual C++ 2010, the `auto` keyword is no longer a C++ storage-class specifier, and the `register` keyword is deprecated.
46+
2. **Visual C++ 2010 and later:** The `auto` keyword is no longer a C++ storage-class specifier, and the `register` keyword is deprecated. **Visual Studio 2017 version 15.3 and later:**(available with [/std:c++latest](../build/reference/std-specify-language-standard-version.md)) The `register` keyword is no longer a supported storage class. The keyword is still reserved in the standard for future use.
47+
```cpp
48+
register int val; // warning C5033: 'register' is no longer a supported storage class
49+
```
4750

4851
## In this section:
4952

@@ -234,18 +237,12 @@ void DoSomething()
234237
For more information, see [Thread Local Storage (TLS)](../parallel/thread-local-storage-tls.md).
235238

236239
## <a name="register"></a> register
237-
In C++11, the `register` keyword is deprecated. It specifies that the variable is to be stored in a machine register, if possible. Only function arguments and local variables can be declared with the register storage class.
238-
239-
```
240-
register int num;
241-
```
242-
243-
Like automatic variables, register variables persist only until the end of the block in which they are declared.
244-
245-
The compiler does not honor user requests for register variables; instead, it makes its own register choices when global optimizations are on. However, all other semantics associated with the `register` keyword are honored by the compiler.
246-
247-
If the address-of operator (**&**) is used on an object that is declared with register, the compiler must put the object in memory rather than a register.
248-
240+
**Visual Studio 2017 version 15.3 and later:**(available with [/std:c++latest](../build/reference/std-specify-language-standard-version.md)) The `register` keyword is no longer a supported storage class. The keyword is still reserved in the standard for future use.
241+
242+
```cpp
243+
register int val; // warning C5033: 'register' is no longer a supported storage class
244+
```
245+
249246
## Example: automatic vs. static initialization
250247
A local automatic object or variable is initialized every time the flow of control reaches its definition. A local static object or variable is initialized the first time the flow of control reaches its definition.
251248

0 commit comments

Comments
 (0)