Skip to content

Commit 42e4999

Browse files
committed
Merging changes synced from https://github.com/MicrosoftDocs/cpp-docs-pr (branch live)
2 parents c5c051f + 60967ae commit 42e4999

File tree

7 files changed

+203
-126
lines changed

7 files changed

+203
-126
lines changed

docs/cpp/tutorial-named-modules-cpp.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
---
22
title: "Named modules tutorial in C++"
3-
ms.date: "12/9/2021"
3+
ms.date: "12/10/2021"
44
ms.topic: "tutorial"
55
helpviewer_keywords: ["modules [C++]", "modules [C++], named modules tutorial"]
66
description: Named modules in C++20 provide a modern alternative to header files.
77
---
88
# Named modules tutorial (C++)
99

10-
This tutorial introduces the basics of creating C++20 modules. Modules are a new way to componentize C++ programs, replacing the venerable header file. You'll learn how modules are an improvement on header files and build an app that shows how to create and consume modules, module partitions, and module implementation files.
10+
This tutorial introduces the basics of creating C++20 modules. Modules are a new way to componentize C++ programs, replacing the venerable header file. You'll learn how modules are an improvement on header files and build an app that shows how to create and consume a module.
11+
12+
In this tutorial, you learn how to:
13+
14+
- Create and import a module
15+
- Create a primary module interface unit
16+
- Create a module partition file
17+
- Create a module unit implementation file
1118

1219
## Prerequisites
1320

docs/error-messages/compiler-errors-1/compiler-error-c2382.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: Compiler Error C2382"
33
title: "Compiler Error C2382"
4-
ms.date: 12/09/2021
4+
ms.date: 12/10/2021
55
f1_keywords: ["C2382"]
66
helpviewer_keywords: ["C2382"]
77
ms.assetid: 4d4436f9-d0d6-4bd0-b8ec-767b89adfb2f
@@ -10,7 +10,15 @@ ms.assetid: 4d4436f9-d0d6-4bd0-b8ec-767b89adfb2f
1010

1111
> '*function*' : redefinition; different exception specifications
1212
13-
This error indicates that a function overload was attempted only on the [exception specification](../../cpp/exception-specifications-throw-cpp.md). Don't change the exception specification in a declaration or definition of the function.
13+
This error indicates that a function overload was attempted only on the [exception specification](../../cpp/exception-specifications-throw-cpp.md).
14+
15+
## Remarks
16+
17+
By default, the compiler considers a `noexcept` specification to be equivalent to a `throw()` or `throw(some_type)` specification. Under [`/Za`](../../build/reference/za-ze-disable-language-extensions.md), this check is more strict.
18+
19+
To resolve this issue, change all declarations and definitions of the function (or the specific function overload) to use the same exception specification.
20+
21+
## Example
1422

1523
The following sample generates C2382:
1624

@@ -21,3 +29,7 @@ void f1(void) noexcept {}
2129
void f1(void) {} // C2382
2230
void f2(void) throw() {} // OK
2331
```
32+
33+
## See also
34+
35+
[`/Za` (Disable language extensions)](../../build/reference/za-ze-disable-language-extensions.md)
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
---
2-
description: "Learn more about: Linker Tools Error LNK1107"
3-
title: "Linker Tools Error LNK1107"
4-
ms.date: "11/04/2016"
2+
description: "Learn more about: Linker tools error LNK1107"
3+
title: "Linker tools error LNK1107"
4+
ms.date: 12/10/2021
55
f1_keywords: ["LNK1107"]
66
helpviewer_keywords: ["LNK1107"]
7-
ms.assetid: a37a893d-5efa-4eba-8f40-6c5518b4b9d0
87
---
9-
# Linker Tools Error LNK1107
8+
# Linker tools error LNK1107
109

11-
invalid or corrupt file: cannot read at location
10+
> invalid or corrupt file: cannot read at location *address*
1211
13-
The tool could not read the file. Recreate the file.
12+
The tool couldn't read the file. The file may be corrupt, or have an unexpected file type.
1413

15-
LNK1107 could also occur if you attempt to pass a module (.dll or .netmodule extension created with [/clr:noAssembly](../../build/reference/clr-common-language-runtime-compilation.md) or [/NOASSEMBLY](../../build/reference/noassembly-create-a-msil-module.md)) to the linker; pass the .obj file instead.
14+
## Remarks
1615

17-
If you compile the following sample:
16+
LNK1107 can occur if a file passed to the linker or related tools is corrupt. To resolve this issue, rebuild the file.
17+
18+
LNK1107 can also occur if your build process puts an unexpected file type in the list of files passed to the tool. The linker and related tools expect to work on specific file types. For example, the linker can use object files, library files, compiled resources, and manifests to create an executable. It can't create an executable by using source files or DLLs. To resolve this issue, verify that your build process passes only the expected file types to the tool. For example, pass *`.obj`*, *`.lib`*, and *`.res`* files, not *`.cpp`*, *`.h`*, *`.dll`*, or *`.rc`* files.
19+
20+
LNK1107 can also occur if you attempt to pass a .NET executable module (A *`.dll`* or *`.netmodule`* file created with [`/clr:noAssembly`](../../build/reference/clr-common-language-runtime-compilation.md) or [`/NOASSEMBLY`](../../build/reference/noassembly-create-a-msil-module.md)) to the linker. To resolve this issue, pass the *`.obj`* file instead.
21+
22+
## Example
23+
24+
Compile this sample by using **`cl /clr /LD LNK1107.cpp`**:
1825

1926
```cpp
2027
// LNK1107.cpp
@@ -25,4 +32,4 @@ public:
2532
};
2633
```
2734
28-
and then specify **link LNK1107.dll** on the command line, you will get LNK1107. To resolve the error, specify **link LNK1107.obj** instead.
35+
If you then specify **`link LNK1107.dll`** on the command line, you'll get LNK1107. To resolve the error, specify **`link LNK1107.obj`** instead.

docs/ide/cpp-linter-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ When you change the check severity level, it changes how the problem is shown in
4646

4747
## Known issues
4848

49-
::: moniker range=">=msvc-170"
49+
::: moniker range="msvc-170"
5050

51-
- The **Comparison/Bitwise Precedence** check isn't available in the initial release of Visual Studio 2022, even though you can configure it in the Options dialog.
51+
- The **Comparison/Bitwise Precedence** check isn't available in the initial release of Visual Studio 2022, even though you can configure it in the Options dialog. It's available starting in Visual Studio 2022 version 17.1.
5252

5353
::: moniker-end
5454
::: moniker range="msvc-160"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: lnt-comparison-bitwise-precedence
3+
description: "Reference for Visual Studio C++ IntelliSense Linter check lnt-comparison-bitwise-precedence."
4+
ms.date: 09/29/2021
5+
f1_keywords: ["lnt-comparison-bitwise-precedence"]
6+
helpviewer_keywords: ["lnt-comparison-bitwise-precedence"]
7+
monikerRange: ">=msvc-160"
8+
---
9+
# `lnt-comparison-bitwise-precedence`
10+
11+
The comparison operator has a higher precedence than the bitwise operator.
12+
13+
The comparison operator will be evaluated first. The result will be implicitly cast to an integer and used as an operand in the bitwise operation. Parentheses are needed to force the expected order of operations.
14+
15+
The `lnt-comparison-bitwise-precedence` check is controlled by the **Comparison/Bitwise Precedence** setting in the C/C++ Code Style options. For information on how to change this setting, see [Configure the linter](cpp-linter-overview.md#configure-the-linter).
16+
17+
## Examples
18+
19+
```cpp
20+
bool is_flag_set(unsigned value, unsigned flag)
21+
{
22+
return value & flag == flag; // Flagged: `flag == flag` is evaluated first.
23+
// Then `value & (int)true` is evaluated which
24+
// returns an incorrect result in most cases.
25+
}
26+
```
27+
28+
```cpp
29+
bool is_flag_set(unsigned value, unsigned flag)
30+
{
31+
return (value & flag) == flag; // Correct
32+
}
33+
```
34+
35+
## How to fix the issue
36+
37+
The fix the linter suggests is to add parentheses around the bitwise operation so it will be evaluated first.
38+
39+
## See also
40+
41+
[IntelliSense code linter for C++ overview](cpp-linter-overview.md)

docs/ide/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ items:
2424
href: ../ide/lnt-arithmetic-overflow.md
2525
- name: lnt-assignment-equality
2626
href: ../ide/lnt-assignment-equality.md
27+
- name: lnt-comparison-bitwise-precedence
28+
href: ../ide/lnt-comparison-bitwise-precedence.md
2729
- name: lnt-integer-float-division
2830
href: ../ide/lnt-integer-float-division.md
2931
- name: lnt-logical-bitwise-mismatch

0 commit comments

Comments
 (0)