Skip to content

Commit 7274928

Browse files
author
Michael Blome
committed
fixes for edit pass
1 parent c92090f commit 7274928

4 files changed

Lines changed: 15 additions & 22 deletions

File tree

docs/cpp/constructors-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Constructors (C++) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "04/06/2018"
55
ms.reviewer: ""
66
ms.suite: ""
77
ms.technology: ["cpp-language"]

docs/cpp/lvalues-and-rvalues-visual-cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Value Categories: Lvalues and Rvalues (Visual C++) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "03/05/2018"
4+
ms.date: "04/06/2018"
55
ms.reviewer: ""
66
ms.suite: ""
77
ms.technology: ["cpp-language"]
@@ -40,7 +40,7 @@ The following diagram illustrates the relationships between the categories:
4040

4141
The following example demonstrates several correct and incorrect usages of lvalues and rvalues:
4242

43-
```
43+
```cpp
4444
// lvalues_and_rvalues2.cpp
4545
int main()
4646
{
Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Program and Linkage (C++) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "04/06/2018"
55
ms.reviewer: ""
66
ms.suite: ""
77
ms.technology: ["cpp-language"]
@@ -16,31 +16,24 @@ manager: "ghogen"
1616
ms.workload: ["cplusplus"]
1717
---
1818
# Program and Linkage (C++)
19-
A translation unit consists of an implementation file (.cpp, .hpp, .cxx, etc) and all the headers that it includes directly or indirectly. A program consists of one or more translation units linked together. The concept of *linkage* refers to the visibility of global symbols (such as variable, type names and function names) within the program as a whole across translation units. The concept of *scope* refers to symbols that are declared within a block such as a namespace, class, or function body. Such symbols are visible only when execution enters the block in which they are defined; the concept of linkage does not apply to them.
2019

21-
Non-const global variables and free functions by default have external linkage; they are visible from any translation unit in the program. You can override this behavior by explicity declaring them as `static` which limits their visiblity to the same translation unit in which they are declared. This meaning of `static` is different than its meaning when applied to local variables. Variables declared as `const` have internal linkage by default.
20+
In a C++ program, each global symbol can be defined only once, even if the program consists of multiple translation units. A translation unit consists of an implementation file (.cpp, .hpp, .cxx, etc) and all the headers that it includes directly or indirectly. A program consists of one or more translation units linked together. The concept of *linkage* refers to the visibility of global symbols (such as variable, type names and function names) within the program as a whole across translation units. The concept of *scope* refers to symbols that are declared within a block such as a namespace, class, or function body. Such symbols are visible only when execution enters the block in which they are defined; the concept of linkage does not apply to them.
2221

23-
In a C++ program, each global symbol can be defined only once.
22+
Non-const global variables and free functions by default have external linkage; they are visible from any translation unit in the program. You can override this behavior by explicity declaring them as `static` which limits their visiblity to the same translation unit in which they are declared. This meaning of `static` is different than its meaning when applied to local variables. Variables declared as `const` have internal linkage by default.
2423

25-
Program execution begins in the translation unit that contains the **main** function. (For more information on translation units, see [Phases of Translation](../preprocessor/phases-of-translation.md), in the *Preprocessor Reference*.) For more information about the **main** function, see [Program Startup: the main Function](../cpp/main-program-startup.md).)
26-
24+
### Extern constexpr linkage
2725

28-
from conformance updates:
29-
Extern constexpr linkage
3026
In earlier versions of Visual Studio, the compiler always gave a constexpr variable internal linkage even when the variable was marked extern. In Visual Studio 2017 version 15.5, a new compiler switch (/Zc:externConstexpr) enables correct standards-conforming behavior. Eventually this will become the default.
3127

32-
C++
33-
Copy
28+
```cpp
29+
extern constexpr int x = 10; //error LNK2005: "int const x" already defined
30+
```
3431

35-
extern constexpr int x = 10;
36-
Output
37-
Copy
38-
error LNK2005: "int const x" already defined
39-
If a header file contains a variable declared extern constexpr, it needs to be marked __declspec(selectany) in order to correctly have its duplicate declarations combined:
40-
41-
C++
42-
Copy
32+
If a header file contains a variable declared extern constexpr, it needs to be marked **__declspec(selectany)** in order to correctly have its duplicate declarations combined:
4333

34+
```cpp
4435
extern constexpr __declspec(selectany) int x = 10;
36+
```
37+
4538
## See Also
4639
[Basic Concepts](../cpp/basic-concepts-cpp.md)

docs/cpp/using-extern-to-specify-linkage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Using extern to Specify Linkage | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "04/06/2018"
55
ms.reviewer: ""
66
ms.suite: ""
77
ms.technology: ["cpp-language"]

0 commit comments

Comments
 (0)