Skip to content

Repo sync for protected CLA branch #3587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions docs/cpp/tutorial-named-modules-cpp.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
---
title: "Named modules tutorial in C++"
ms.date: "12/9/2021"
ms.date: "12/10/2021"
ms.topic: "tutorial"
helpviewer_keywords: ["modules [C++]", "modules [C++], named modules tutorial"]
description: Named modules in C++20 provide a modern alternative to header files.
---
# Named modules tutorial (C++)

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.
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.

In this tutorial, you learn how to:

- Create and import a module
- Create a primary module interface unit
- Create a module partition file
- Create a module unit implementation file

## Prerequisites

Expand Down
16 changes: 14 additions & 2 deletions docs/error-messages/compiler-errors-1/compiler-error-c2382.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: Compiler Error C2382"
title: "Compiler Error C2382"
ms.date: 12/09/2021
ms.date: 12/10/2021
f1_keywords: ["C2382"]
helpviewer_keywords: ["C2382"]
ms.assetid: 4d4436f9-d0d6-4bd0-b8ec-767b89adfb2f
Expand All @@ -10,7 +10,15 @@ ms.assetid: 4d4436f9-d0d6-4bd0-b8ec-767b89adfb2f

> '*function*' : redefinition; different exception specifications

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.
This error indicates that a function overload was attempted only on the [exception specification](../../cpp/exception-specifications-throw-cpp.md).

## Remarks

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.

To resolve this issue, change all declarations and definitions of the function (or the specific function overload) to use the same exception specification.

## Example

The following sample generates C2382:

Expand All @@ -21,3 +29,7 @@ void f1(void) noexcept {}
void f1(void) {} // C2382
void f2(void) throw() {} // OK
```

## See also

[`/Za` (Disable language extensions)](../../build/reference/za-ze-disable-language-extensions.md)
27 changes: 17 additions & 10 deletions docs/error-messages/tool-errors/linker-tools-error-lnk1107.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
---
description: "Learn more about: Linker Tools Error LNK1107"
title: "Linker Tools Error LNK1107"
ms.date: "11/04/2016"
description: "Learn more about: Linker tools error LNK1107"
title: "Linker tools error LNK1107"
ms.date: 12/10/2021
f1_keywords: ["LNK1107"]
helpviewer_keywords: ["LNK1107"]
ms.assetid: a37a893d-5efa-4eba-8f40-6c5518b4b9d0
---
# Linker Tools Error LNK1107
# Linker tools error LNK1107

invalid or corrupt file: cannot read at location
> invalid or corrupt file: cannot read at location *address*

The tool could not read the file. Recreate the file.
The tool couldn't read the file. The file may be corrupt, or have an unexpected file type.

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.
## Remarks

If you compile the following sample:
LNK1107 can occur if a file passed to the linker or related tools is corrupt. To resolve this issue, rebuild the file.

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.

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.

## Example

Compile this sample by using **`cl /clr /LD LNK1107.cpp`**:

```cpp
// LNK1107.cpp
Expand All @@ -25,4 +32,4 @@ public:
};
```

and then specify **link LNK1107.dll** on the command line, you will get LNK1107. To resolve the error, specify **link LNK1107.obj** instead.
If you then specify **`link LNK1107.dll`** on the command line, you'll get LNK1107. To resolve the error, specify **`link LNK1107.obj`** instead.
4 changes: 2 additions & 2 deletions docs/ide/cpp-linter-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ When you change the check severity level, it changes how the problem is shown in

## Known issues

::: moniker range=">=msvc-170"
::: moniker range="msvc-170"

- 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.
- 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.

::: moniker-end
::: moniker range="msvc-160"
Expand Down
41 changes: 41 additions & 0 deletions docs/ide/lnt-comparison-bitwise-precedence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
title: lnt-comparison-bitwise-precedence
description: "Reference for Visual Studio C++ IntelliSense Linter check lnt-comparison-bitwise-precedence."
ms.date: 09/29/2021
f1_keywords: ["lnt-comparison-bitwise-precedence"]
helpviewer_keywords: ["lnt-comparison-bitwise-precedence"]
monikerRange: ">=msvc-160"
---
# `lnt-comparison-bitwise-precedence`

The comparison operator has a higher precedence than the bitwise operator.

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.

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).

## Examples

```cpp
bool is_flag_set(unsigned value, unsigned flag)
{
return value & flag == flag; // Flagged: `flag == flag` is evaluated first.
// Then `value & (int)true` is evaluated which
// returns an incorrect result in most cases.
}
```

```cpp
bool is_flag_set(unsigned value, unsigned flag)
{
return (value & flag) == flag; // Correct
}
```

## How to fix the issue

The fix the linter suggests is to add parentheses around the bitwise operation so it will be evaluated first.

## See also

[IntelliSense code linter for C++ overview](cpp-linter-overview.md)
2 changes: 2 additions & 0 deletions docs/ide/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ items:
href: ../ide/lnt-arithmetic-overflow.md
- name: lnt-assignment-equality
href: ../ide/lnt-assignment-equality.md
- name: lnt-comparison-bitwise-precedence
href: ../ide/lnt-comparison-bitwise-precedence.md
- name: lnt-integer-float-division
href: ../ide/lnt-integer-float-division.md
- name: lnt-logical-bitwise-mismatch
Expand Down
Loading