tmp/tmp1w_siwq_/{from.md → to.md}
RENAMED
|
@@ -51,16 +51,16 @@ with external linkage declared within the *linkage-specification*.
|
|
| 51 |
``` cpp
|
| 52 |
extern "C" void f1(void(*pf)(int));
|
| 53 |
// the name f1 and its function type have C language
|
| 54 |
// linkage; pf is a pointer to a C function
|
| 55 |
extern "C" typedef void FUNC();
|
| 56 |
-
FUNC f2; // the name f2 has
|
| 57 |
// function's type has C language linkage
|
| 58 |
extern "C" FUNC f3; // the name of function f3 and the function's type
|
| 59 |
// have C language linkage
|
| 60 |
-
void (*pf2)(FUNC*); // the name of the variable pf2 has
|
| 61 |
-
// the type of pf2 is pointer to
|
| 62 |
// takes one parameter of type pointer to C function
|
| 63 |
extern "C" {
|
| 64 |
static void f4(); // the name of the function f4 has
|
| 65 |
// internal linkage (not C language
|
| 66 |
// linkage) and the function's type
|
|
@@ -68,24 +68,23 @@ extern "C" {
|
|
| 68 |
}
|
| 69 |
|
| 70 |
extern "C" void f5() {
|
| 71 |
extern void f4(); // OK: Name linkage (internal)
|
| 72 |
// and function type linkage (C
|
| 73 |
-
// language linkage)
|
| 74 |
// previous declaration.
|
| 75 |
}
|
| 76 |
|
| 77 |
extern void f4(); // OK: Name linkage (internal)
|
| 78 |
// and function type linkage (C
|
| 79 |
-
// language linkage)
|
| 80 |
// previous declaration.
|
| 81 |
-
}
|
| 82 |
|
| 83 |
void f6() {
|
| 84 |
extern void f4(); // OK: Name linkage (internal)
|
| 85 |
// and function type linkage (C
|
| 86 |
-
// language linkage)
|
| 87 |
// previous declaration.
|
| 88 |
}
|
| 89 |
```
|
| 90 |
|
| 91 |
A C language linkage is ignored in determining the language linkage of
|
|
@@ -180,13 +179,13 @@ extern "C" {
|
|
| 180 |
int i; // definition
|
| 181 |
}
|
| 182 |
extern "C" static void g(); // error
|
| 183 |
```
|
| 184 |
|
| 185 |
-
Because the language linkage is part of a function type, when
|
| 186 |
-
|
| 187 |
-
refers is considered a C function.
|
| 188 |
|
| 189 |
Linkage from C++to objects defined in other languages and to objects
|
| 190 |
defined in C++from other languages is implementation-defined and
|
| 191 |
language-dependent. Only where the object layout strategies of two
|
| 192 |
language implementations are similar enough can such linkage be
|
|
|
|
| 51 |
``` cpp
|
| 52 |
extern "C" void f1(void(*pf)(int));
|
| 53 |
// the name f1 and its function type have C language
|
| 54 |
// linkage; pf is a pointer to a C function
|
| 55 |
extern "C" typedef void FUNC();
|
| 56 |
+
FUNC f2; // the name f2 has C++language linkage and the
|
| 57 |
// function's type has C language linkage
|
| 58 |
extern "C" FUNC f3; // the name of function f3 and the function's type
|
| 59 |
// have C language linkage
|
| 60 |
+
void (*pf2)(FUNC*); // the name of the variable pf2 has C++linkage and
|
| 61 |
+
// the type of pf2 is pointer to C++function that
|
| 62 |
// takes one parameter of type pointer to C function
|
| 63 |
extern "C" {
|
| 64 |
static void f4(); // the name of the function f4 has
|
| 65 |
// internal linkage (not C language
|
| 66 |
// linkage) and the function's type
|
|
|
|
| 68 |
}
|
| 69 |
|
| 70 |
extern "C" void f5() {
|
| 71 |
extern void f4(); // OK: Name linkage (internal)
|
| 72 |
// and function type linkage (C
|
| 73 |
+
// language linkage) obtained from
|
| 74 |
// previous declaration.
|
| 75 |
}
|
| 76 |
|
| 77 |
extern void f4(); // OK: Name linkage (internal)
|
| 78 |
// and function type linkage (C
|
| 79 |
+
// language linkage) obtained from
|
| 80 |
// previous declaration.
|
|
|
|
| 81 |
|
| 82 |
void f6() {
|
| 83 |
extern void f4(); // OK: Name linkage (internal)
|
| 84 |
// and function type linkage (C
|
| 85 |
+
// language linkage) obtained from
|
| 86 |
// previous declaration.
|
| 87 |
}
|
| 88 |
```
|
| 89 |
|
| 90 |
A C language linkage is ignored in determining the language linkage of
|
|
|
|
| 179 |
int i; // definition
|
| 180 |
}
|
| 181 |
extern "C" static void g(); // error
|
| 182 |
```
|
| 183 |
|
| 184 |
+
Because the language linkage is part of a function type, when
|
| 185 |
+
indirecting through a pointer to C function, the function to which the
|
| 186 |
+
resulting lvalue refers is considered a C function.
|
| 187 |
|
| 188 |
Linkage from C++to objects defined in other languages and to objects
|
| 189 |
defined in C++from other languages is implementation-defined and
|
| 190 |
language-dependent. Only where the object layout strategies of two
|
| 191 |
language implementations are similar enough can such linkage be
|