Skip to content

Commit 6c275bf

Browse files
author
mikeblome
committed
changed title and made small edits to linkage topic
1 parent cca39be commit 6c275bf

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

docs/cpp/extern-cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.assetid: 1e2f0ae3-ae98-4410-85b5-222d6abc865a
77
---
88
# extern (C++)
99

10-
The **extern** keyword is applied to a global variable, function or template declaration to specify that the name of that thing has *external linkage*. For background information on linkage and why the use of global variables is discouraged, see [Program and linkage](program-and-linkage-cpp.md).
10+
The **extern** keyword is applied to a global variable, function or template declaration to specify that the name of that thing has *external linkage*. For background information on linkage and why the use of global variables is discouraged, see [Translation units and linkage](program-and-linkage-cpp.md).
1111

1212
The **extern** keyword has four meanings depending on the context:
1313

@@ -124,7 +124,7 @@ extern "C" int CFunc2(); // Error: not the first declaration of
124124
## See also
125125
126126
[Keywords](../cpp/keywords-cpp.md)<br/>
127-
[Program and linkage](program-and-linkage-cpp.md)<br/>
127+
[Translation units and linkage](program-and-linkage-cpp.md)<br/>
128128
[extern Storage-Class Specifier in C](../c-language/extern-storage-class-specifier.md)<br/>
129129
[Behavior of Identifiers in C](../c-language/behavior-of-identifiers.md)<br/>
130130
[Linkage in C](../c-language/linkage.md)

docs/cpp/function-call-operator-parens.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ int main() {
161161
}
162162
```
163163
164-
Functions can be called recursively. For more information about function declarations, see [Functions](functions-cpp.md). Related material is in [Program and Linkage](../cpp/program-and-linkage-cpp.md).
164+
Functions can be called recursively. For more information about function declarations, see [Functions](functions-cpp.md). Related material is in [Translation units and linkage](../cpp/program-and-linkage-cpp.md).
165165
166166
## See also
167167

docs/cpp/functions-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Optional parts of a function declaration are:
8080

8181
```
8282

83-
For more information, see [Program and Linkage](../cpp/program-and-linkage-cpp.md).
83+
For more information, see [Translation units and linkage](../cpp/program-and-linkage-cpp.md).
8484

8585
1. **inline**, which instructs the compiler to replace every call to the function with the function code itself. inlining can help performance in scenarios where a function executes quickly and is invoked repeatedly in a performance-critical section of code.
8686

docs/cpp/lexical-conventions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ This section introduces the fundamental elements of a C++ program. You use these
3131
## See also
3232

3333
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
34-
[Program and linkage](program-and-linkage-cpp.md)
34+
[Translation units and linkage](program-and-linkage-cpp.md)

docs/cpp/program-and-linkage-cpp.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
---
2-
title: "Programs and Linkage (C++)"
3-
ms.date: "04/09/2018"
2+
title: "Translation units and linkage (C++)"
3+
ms.date: "12/11/2019"
44
ms.assetid: a6493ba0-24e2-4c89-956e-9da1dea660cb
55
---
6-
# Program and Linkage (C++)
6+
# Translation units and Linkage
77

8-
In a C++ program, a *symbol*, for example a variable or function name, can be declared any number of times within its scope, but it can only be defined once. This is the One Definition Rule (ODR). A *declaration* introduces (or re-introduces) a name into the program. A *definition* introduces a name and, in the case of a variable, explicitly initializes it. A *function definition* consists of the signature plus the function body.
8+
In a C++ program, a *symbol*, for example a variable or function name, can be declared any number of times within its scope, but it can only be defined once. This is the One Definition Rule (ODR). A *declaration* introduces (or re-introduces) a name into the program. A *definition* introduces a name and, in the case of a variable, explicitly initializes it. A *function definition* consists of the signature plus the function body. A class definition consists of the class name followed by a block that lists all the class members. (The bodies of member functions may optionally be defined separately in another file.)
99

1010
These are declarations:
1111

1212
```cpp
1313
int i;
1414
int f(int x);
15+
class C;
1516
```
1617
1718
These are definitions:
1819
1920
```cpp
2021
int i{42};
2122
int f(int x){ return x * i; }
23+
class C {
24+
public:
25+
void DoSomething();
26+
};
2227
```
2328

2429
A program consists of one or more *translation units*. A translation unit consists of an implementation file (.cpp, .cxx, etc.) and all the headers (.h, .hpp, etc.) that it includes directly or indirectly. Each translation unit is compiled independently by the compiler, after which the linker merges the compiled translation units into a single *program*. Violations of the ODR rule typically show up as linker errors when the same name has two different definitions in different translation units.

docs/toc.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3727,13 +3727,8 @@
37273727
href: cpp/scope-visual-cpp.md
37283728
- name: Header files
37293729
href: cpp/header-files-cpp.md
3730-
- name: Program and linkage
3731-
expanded: false
3732-
items:
3733-
- name: Program and linkage
3734-
href: cpp/program-and-linkage-cpp.md
3735-
- name: extern
3736-
href: cpp/using-extern-to-specify-linkage.md
3730+
- name: Translation units and linkage
3731+
href: cpp/program-and-linkage-cpp.md
37373732
- name: Startup and termination
37383733
expanded: false
37393734
items:

0 commit comments

Comments
 (0)