Skip to content

Commit 7e7fc3e

Browse files
authored
Merge pull request #5494 from MicrosoftDocs/main
3/11/2024 AM Publish
2 parents 9c729c1 + 770646f commit 7e7fc3e

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
---
22
description: "Learn more about: Compiler Error C2526"
33
title: "Compiler Error C2526"
4-
ms.date: "11/04/2016"
4+
ms.date: "03/08/2024"
55
f1_keywords: ["C2526"]
66
helpviewer_keywords: ["C2526"]
7-
ms.assetid: 0f8c554c-f990-457e-bcae-b6f273481825
87
---
98
# Compiler Error C2526
109

1110
'identifier1' : C linkage function cannot return C++ class 'identifier2'
1211

1312
A function defined with C linkage cannot return a user-defined type.
13+
14+
The following sample generates C2526:
15+
16+
```cpp
17+
// C2526.cpp
18+
// compile with: /c
19+
template <typename T>
20+
class A {};
21+
22+
extern "C" A<int> func() // C2526
23+
{
24+
return A<int>();
25+
}
26+
```
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
---
22
description: "Learn more about: Compiler Error C2537"
33
title: "Compiler Error C2537"
4-
ms.date: "11/04/2016"
4+
ms.date: "03/08/2024"
55
f1_keywords: ["C2537"]
66
helpviewer_keywords: ["C2537"]
7-
ms.assetid: aee81d8e-300e-4a8b-b6c4-b3828398b34e
87
---
98
# Compiler Error C2537
109

1110
'specifier' : illegal linkage specification
1211

13-
Possible causes:
14-
15-
1. The linkage specifier is not supported. Only the "C" linkage specifier is supported.
16-
17-
1. "C" linkage is specified for more than one function in a set of overloaded functions. This is not allowed.
12+
The linkage specifier is not supported. Only the "C" and "C++" linkage specifiers are supported.
1813

1914
The following sample generates C2537:
2015

2116
```cpp
2217
// C2537.cpp
2318
// compile with: /c
24-
extern "c" void func(); // C2537
19+
extern "c" void func1(); // C2537
2520
extern "C" void func2(); // OK
21+
extern "C++" void func3(); // OK
2622
```

docs/porting/binary-compat-2015-2017.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "C++ binary compatibility 2015-2022"
33
description: "Describes how binary compatibility works between compiled C++ files in Visual Studio 2015, 2017, 2019, and 2022. One Microsoft Visual C++ Redistributable package works for all three versions."
4-
ms.date: 10/22/2021
4+
ms.date: 03/07/2024
55
helpviewer_keywords: ["binary compatibility, Visual C++"]
66
---
77
# C++ binary compatibility between Visual Studio versions
@@ -14,10 +14,11 @@ We've changed this behavior in Visual Studio 2015 and later versions. The runtim
1414

1515
There are three important restrictions on binary compatibility between the v140, v141, v142, and v143 toolsets and minor numbered version updates:
1616

17-
- You can mix binaries built by different versions of the v140, v141, v142, and v143 toolsets. However, you must link by using a toolset at least as recent as the most recent binary in your app. Here's an example: you can link an app compiled using any 2017 toolset (v141, versions 15.0 through 15.9) to a static library compiled using, say, Visual Studio 2019 version 16.2 (v142). You just have to link them by using a version 16.2 or later toolset. You can link a version 16.2 library to a version 16.4 app as long as you use a 16.4 or later toolset.
18-
17+
- Binaries created with different versions of the v140, v141, v142, and v143 toolsets can be combined. The key rule is that the linker should only work with inputs built by a toolset that is the same version (or earlier) as itself. This applies to apps, import libraries, static libraries, and other files as described in [LINK input files](../build/reference/link-input-files.md). In some cases, an import library for an [implicitly linked](../build/linking-an-executable-to-a-dll.md#implicit-linking) DLL built by a later version of the toolset can be linked using an earlier version of the toolset--especially if the import library strictly uses `extern "C"` for the imports/exports. Here are some examples of what this all means:
18+
- An app compiled with a 2017 toolset (v141, versions 15.0 to 15.9) can be linked to a static library compiled with Visual Studio 2022 version 17.8 (v143), but the linking must be done using a version 17.8 or later toolset.
19+
- Apps and libraries built using VS 2015, 2017, 2019, or 2022 can be linked together, but the linking must be done using a version of the toolset that is as recent as, or more recent than, the most recent toolset used to build any of the binaries you pass to the linker. For example, given three binaries built with toolsets from VS 2015 version 14.3, VS 2017 version 15.9, and VS 2019 version 16.11, you can link them using any toolset version that is 16.11 or later.
20+
- If a DLL is built with a newer toolset, the import library can sometimes be used with older toolsets if all of the exports follow the C language calling convention (`extern "C"`). However, the only officially supported case is consuming a newer windows SDK with an older toolset.
1921
- The Redistributable your app uses has a similar binary-compatibility restriction. When you mix binaries built by different supported versions of the toolset, the Redistributable version must be at least as new as the latest toolset used by any app component.
20-
2122
- Static libraries or object files compiled using the [`/GL` (Whole program optimization)](../build/reference/gl-whole-program-optimization.md) compiler switch or linked using [`/LTCG` (Link-time code generation)](../build/reference/ltcg-link-time-code-generation.md) *aren't* binary-compatible across versions, including minor version updates. All object files and libraries compiled using **`/GL`** and **`/LTCG`** must use exactly the same toolset for the compile and the final link. For example, code built by using **`/GL`** in the Visual Studio 2019 version 16.7 toolset can't be linked to code built by using **`/GL`** in the Visual Studio 2019 version 16.8 toolset. The compiler emits [Fatal error C1047](../error-messages/compiler-errors-1/fatal-error-c1047.md).
2223

2324
## Upgrade the Microsoft Visual C++ Redistributable from Visual Studio 2015 and later

docs/standard-library/file-clock-class.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: file_clock class"
33
title: "file_clock class"
4-
ms.date: 08/19/2021
4+
ms.date: 3/8/2024
55
f1_keywords: ["chrono/std::chrono::file_clock", "chrono/std::chrono::file_clock::now", "chrono/std::chrono::file_clock::to_utc", "chrono/std::chrono::file_clock::from_utc", "chrono/std::chrono::file_clock::is_steady Constant"]
66
---
77

@@ -12,7 +12,7 @@ This clock can represent the range and resolution of file time values used in th
1212
## Syntax
1313

1414
```cpp
15-
using file_clock = std::filesystem::_File_time_clock. // C++20
15+
using file_clock = std::filesystem::_File_time_clock; // C++20
1616
```
1717

1818
## Remarks

0 commit comments

Comments
 (0)