Skip to content

Repo sync for protected CLA branch #3585

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 10, 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
12 changes: 10 additions & 2 deletions docs/build/reference/makefile-preprocessing.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
description: "Learn more about: Makefile Preprocessing"
title: "Makefile Preprocessing"
title: "Makefile preprocessing"
ms.date: 09/30/2021
f1_keywords: ["!UNDEF", "!INCLUDE", "!IFNDEF", "!MESSAGE"]
helpviewer_keywords: ["preprocessing makefiles", "makefiles, preprocessing", "!CMDSWITCHES directive", "!ELSE directive", "!ELSEIF directive", "!ELSEIFDEF directive", "!ELSEIFNDEF directive", "!ENDIF directive", "!ERROR directive", "!IF directive", "!IFDEF directive", "!IFNDEF directive", "!INCLUDE directive", "!MESSAGE directive", "!UNDEF directive", "directives, makefile preprocessing", "preprocessing directives, makefiles", "NMAKE program, expressions", "NMAKE program, preprocessor directives", "makefiles, preprocessing directives", "expressions [C++], makefile preprocessing", "operators [C++], makefile preprocessing", "EXIST operator", "preprocessing NMAKE makefile operators", "NMAKE program, operators", "DEFINED operator", "makefiles, preprocessing operators"]
---
# Makefile Preprocessing
# Makefile preprocessing

You can control the NMAKE session by using preprocessing directives and expressions. Preprocessing instructions can be placed in the makefile or in *`Tools.ini`*. Using directives, you can conditionally process your makefile, display error messages, include other makefiles, undefine a macro, and turn certain options on or off.

Expand Down Expand Up @@ -129,6 +129,14 @@ Expressions can use the following operators. The operators of equal precedence a

To use a command's exit code during preprocessing, specify the command, with any arguments, within brackets (**`[ ]`**). Any macros are expanded before the command is executed. NMAKE replaces the command specification with the command's exit code, which can be used in an expression to control preprocessing.

### Example

```Makefile
!IF [my_command.exe arg1 arg2] != 0
!MESSAGE my_command.exe failed!
!ENDIF
```

## See also

[NMAKE Reference](nmake-reference.md)
10 changes: 5 additions & 5 deletions docs/build/reference/z7-zi-zi-debug-information-format.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
description: "Learn more about: /Z7, /Zi, /ZI (Debug Information Format)"
title: "/Z7, /Zi, /ZI (Debug Information Format)"
ms.date: "07/06/2020"
ms.date: 12/09/2021
f1_keywords: ["VC.Project.VCCLCompilerTool.DebugInformationFormat", "/ZI", "/Zi", "/Z7", "VC.Project.VCCLWCECompilerTool.DebugInformationFormat"]
helpviewer_keywords: ["C7 compatible compiler option [C++]", "Debug Information Format compiler option", "ZI compiler option", "-Zi compiler option [C++]", "/ZI compiler option [C++]", "Z7 compiler option [C++]", "debugging [C++], debug information files", "Zi compiler option [C++]", "/Zi compiler option [C++]", "program database compiler option [C++]", "full symbolic debugging information", "/Z7 compiler option [C++]", "line numbers only compiler option [C++]", "cl.exe compiler, debugging options", "-Z7 compiler option [C++]"]
---
# /Z7, /Zi, /ZI (Debug Information Format)
# `/Z7`, `/Zi`, `/ZI` (Debug Information Format)

The **`/Z7`**, **`/Zi`**, and **`/ZI`** compiler options specify the type of debugging information created for your program, and whether this information is kept in object files or in a program database (PDB) file.

Expand All @@ -23,15 +23,15 @@ When you specify a debug option, the compiler produces symbol names for function

By default, if no debug information format option is specified, the compiler produces no debugging information, so compilation is faster.

### /Z7
### `/Z7`

The **`/Z7`** option produces object files that also contain full symbolic debugging information for use with the debugger. These object files and any libraries built from them can be substantially larger than files that have no debugging information. The symbolic debugging information includes the names and types of variables, functions, and line numbers. No PDB file is produced by the compiler. However, a PDB file can still be generated from these object files or libraries if the linker is passed the **`/DEBUG`** option.

For distributors of debug versions of third-party libraries, there's an advantage to not having a PDB file. However, the object files for any precompiled headers are necessary during the library link phase, and for debugging. If there's only type information (and no code) in the *`.pch`* object file, you must also use the [`/Yl` (Inject PCH Reference for Debug Library)](yl-inject-pch-reference-for-debug-library.md) option, which is enabled by default, when you build the library.

The deprecated [`/Gm` (Enable Minimal Rebuild)](gm-enable-minimal-rebuild.md) option is unavailable when **`/Z7`** is specified.

### /Zi
### `/Zi`

The **`/Zi`** option produces a separate PDB file that contains all the symbolic debugging information for use with the debugger. The debugging information isn't included in the object files or executable, which makes them much smaller.

Expand All @@ -43,7 +43,7 @@ The compiler names the PDB file *`<project>.pdb`*, where *`<project>`* is the na

If you create a library from objects that were compiled using **`/Zi`**, the associated PDB file must be available when the library is linked to a program. That means, if you distribute the library, you must also distribute the PDB file. To create a library that contains debugging information without using PDB files, you must select the **`/Z7`** option. If you use the precompiled headers options, debugging information for both the precompiled header and the rest of the source code is placed in the PDB file.

### /ZI
### `/ZI`

The **`/ZI`** option is similar to **`/Zi`**, but it produces a PDB file in a format that supports the [Edit and Continue](/visualstudio/debugger/edit-and-continue-visual-cpp) feature. To use Edit and Continue debugging features, you must use this option. The Edit and Continue feature is useful for developer productivity, but can cause issues in code size, performance, and compiler conformance. Because most optimizations are incompatible with Edit and Continue, using **`/ZI`** disables any `#pragma optimize` statements in your code. The **`/ZI`** option is also incompatible with use of the [`__LINE__` predefined macro](../../preprocessor/predefined-macros.md); code compiled with **`/ZI`** can't use `__LINE__` as a non-type template argument, although `__LINE__` can be used in macro expansions.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Walkthrough: Create and use your own Dynamic Link Library (C++)"
description: "Use C++ to create a Windows dynamic-link library (DLL) in Visual Studio."
ms.custom: "contperf-fy21q2"
ms.topic: tutorial
ms.date: "08/22/2019"
ms.date: 12/09/2021
helpviewer_keywords: ["libraries [C++], DLLs", "DLLs [C++], walkthroughs"]
---
# Walkthrough: Create and use your own Dynamic Link Library (C++)
Expand All @@ -30,6 +30,8 @@ This walkthrough creates two Visual Studio solutions; one that builds the DLL, a

This walkthrough doesn't cover some common situations. The code doesn't show the use of C++ DLLs by other programming languages. It doesn't show how to [create a resource-only DLL](creating-a-resource-only-dll.md), or how to use [explicit linking](linking-an-executable-to-a-dll.md#linking-explicitly) to load DLLs at run-time rather than at load-time. Rest assured, you can use MSVC and Visual Studio to do all these things.

Even though the code of the DLL is written in C++, we've used C-style interfaces for the exported functions. There are two main reasons for this: First, many other languages support imports of C-style functions. The client app doesn't have to be written in C++. Second, it avoids some common pitfalls related to exported classes and member functions. It's easy to make hard-to-diagnose errors when exporting classes, since everything referred to within a class declaration has to have an instantiation that's also exported. This restriction applies to DLLs, but not static libraries. If your classes are plain-old-data style, you shouldn't run into this issue.

For links to more information about DLLs, see [Create C/C++ DLLs in Visual Studio](dlls-in-visual-cpp.md). For more information about implicit linking and explicit linking, see [Determine which linking method to use](linking-an-executable-to-a-dll.md#determining-which-linking-method-to-use). For information about creating C++ DLLs for use with programming languages that use C-language linkage conventions, see [Exporting C++ functions for use in C-language executables](exporting-cpp-functions-for-use-in-c-language-executables.md). For information about how to create DLLs for use with .NET languages, see [Calling DLL Functions from Visual Basic Applications](calling-dll-functions-from-visual-basic-applications.md).

## Prerequisites
Expand Down
33 changes: 15 additions & 18 deletions docs/c-language/parsing-c-command-line-arguments.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
title: "Parsing C Command-Line Arguments"
title: "Parsing C command-line arguments"
description: "Learn how the Microsoft C runtime startup code interprets command-line arguments to create the argv and argc parameters."
ms.date: 11/09/2020
ms.date: 12/09/2021
helpviewer_keywords: ["quotation marks, command-line arguments", "double quotation marks", "double quote marks", "command line, parsing", "parsing, command-line arguments", "startup code, parsing command-line arguments"]
ms.assetid: ffce8037-2811-45c4-8db4-1ed787859c80
---
# Parsing C Command-Line Arguments
# Parsing C command-line arguments

**Microsoft Specific**

Microsoft C startup code uses the following rules when interpreting arguments given on the operating system command line:

- Arguments are delimited by white space, which is either a space or a tab.
- Arguments are delimited by whitespace characters, which are either spaces or tabs.

- The first argument (`argv[0]`) is treated specially. It represents the program name. Because it must be a valid pathname, parts surrounded by double quote marks (**`"`**) are allowed. The double quote marks aren't included in the `argv[0]` output. The parts surrounded by double quote marks prevent interpretation of a space or tab character as the end of the argument. The later rules in this list don't apply.

- A string surrounded by double quote marks is interpreted as a single argument, whether or not it contains white space. A quoted string can be embedded in an argument. The caret (**`^`**) isn't recognized as an escape character or delimiter. Within a quoted string, a pair of double quote marks is interpreted as a single escaped double quote mark. If the command line ends before a closing double quote mark is found, then all the characters read so far are output as the last argument.
- A string surrounded by double quote marks is interpreted as a single argument, whether it contains whitespace characters or not. A quoted string can be embedded in an argument. The caret (**`^`**) isn't recognized as an escape character or delimiter. Within a quoted string, a pair of double quote marks is interpreted as a single escaped double quote mark. If the command line ends before a closing double quote mark is found, then all the characters read so far are output as the last argument.

- A double quote mark preceded by a backslash (**`\"`**) is interpreted as a literal double quote mark (**`"`**).

Expand All @@ -27,14 +27,14 @@ Microsoft C startup code uses the following rules when interpreting arguments gi

This list illustrates the rules above by showing the interpreted result passed to `argv` for several examples of command-line arguments. The output listed in the second, third, and fourth columns is from the ARGS.C program that follows the list.

|Command-Line Input|argv[1]|argv[2]|argv[3]|
|-------------------------|---------------|---------------|---------------|
|`"a b c" d e`|`a b c`|`d`|`e`|
|`"ab\"c" "\\" d`|`ab"c`|`\`|`d`|
|`a\\\b d"e f"g h`|`a\\\b`|`de fg`|`h`|
|`a\\\"b c d`|`a\"b`|`c`|`d`|
|`a\\\\"b c" d e`|`a\\b c`|`d`|`e`|
|`a"b"" c d`|`ab" c d`|||
| Command-line input | `argv[1]` | `argv[2]` | `argv[3]` |
|--|--|--|--|
| `"a b c" d e` | `a b c` | `d` | `e` |
| `"ab\"c" "\\" d` | `ab"c` | `\` | `d` |
| `a\\\b d"e f"g h` | `a\\\b` | `de fg` | `h` |
| `a\\\"b c d` | `a\"b` | `c` | `d` |
| `a\\\\"b c" d e` | `a\\b c` | `d` | `e` |
| `a"b"" c d` | `ab" c d` | | |

## Example

Expand Down Expand Up @@ -68,17 +68,14 @@ char **envp ) // Array of environment variable strings
}
```

## Comments

One example of output from this program is:

```
Command-line arguments:
argv[0] C:\MSC\TEST.EXE
argv[0] C:\MSC\ARGS.EXE

Environment variables:
COMSPEC=C:\NT\SYSTEM32\CMD.EXE

PATH=c:\nt;c:\binb;c:\binr;c:\nt\system32;c:\word;c:\help;c:\msc;c:\;
PROMPT=[$p]
TEMP=c:\tmp
Expand All @@ -91,4 +88,4 @@ Environment variables:

## See also

[main Function and Program Execution](../c-language/main-function-and-program-execution.md)
[`main` function and program execution](../c-language/main-function-and-program-execution.md)
32 changes: 17 additions & 15 deletions docs/cpp/left-shift-and-right-shift-operators-input-and-output.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
---
description: "Learn more about: Left Shift and Right Shift Operators (>> and <<)"
title: "Left Shift and Right Shift Operators (>> and <<)"
ms.date: "08/13/2018"
description: "Learn more about: Left shift and right shift operators ('<<' and '>>')"
title: "Left shift and right shift operators ('<<' and '>>')"
ms.date: 12/09/2021
f1_keywords: ["<<", ">>"]
helpviewer_keywords: ["<< operator [C++], with specific objects", "left shift operators [C++]", "right shift operators [C++]", "bitwise-shift operators [C++]", ">> operator", "shift operators [C++]", "operators [C++], shift"]
ms.assetid: 25fa0cbb-5fdd-4657-8745-b35f7d8f1606
---
# Left Shift and Right Shift Operators (`<<` and `>>`)
# Left shift and right shift operators (`<<` and `>>`)

The bitwise shift operators are the right-shift operator (**`>>`**), which moves the bits of *shift-expression* to the right, and the left-shift operator (**`<<`**), which moves the bits of *shift-expression* to the left. <sup>1</sup>
The bitwise shift operators are the right-shift operator (**`>>`**), which moves the bits of an integer or enumeration type expression to the right, and the left-shift operator (**`<<`**), which moves the bits to the left. <sup>1</sup>

## Syntax

> *shift-expression* `<<` *additive-expression*\
> *shift-expression* `>>` *additive-expression*
*`shift-expression`*:\
&emsp *`additive-expression`*\
&emsp *`shift-expression`* **`<<`** *`additive-expression`*\
&emsp *`shift-expression`* **`>>`** *`additive-expression`*

## Remarks

Expand All @@ -22,7 +24,7 @@ The bitwise shift operators are the right-shift operator (**`>>`**), which moves

## Left Shifts

The left-shift operator causes the bits in *shift-expression* to be shifted to the left by the number of positions specified by *additive-expression*. The bit positions that have been vacated by the shift operation are zero-filled. A left shift is a logical shift (the bits that are shifted off the end are discarded, including the sign bit). For more information about the kinds of bitwise shifts, see [Bitwise shifts](https://en.wikipedia.org/wiki/Bitwise_shift).
The left-shift operator causes the bits in *`shift-expression`* to be shifted to the left by the number of positions specified by *`additive-expression`*. The bit positions that have been vacated by the shift operation are zero-filled. A left shift is a logical shift (the bits that are shifted off the end are discarded, including the sign bit). For more information about the kinds of bitwise shifts, see [Bitwise shifts](https://en.wikipedia.org/wiki/Bitwise_shift).

The following example shows left-shift operations using unsigned numbers. The example shows what is happening to the bits by representing the value as a bitset. For more information, see [bitset Class](../standard-library/bitset-class.md).

Expand Down Expand Up @@ -72,7 +74,7 @@ int main() {

## Right Shifts

The right-shift operator causes the bit pattern in *shift-expression* to be shifted to the right by the number of positions specified by *additive-expression*. For unsigned numbers, the bit positions that have been vacated by the shift operation are zero-filled. For signed numbers, the sign bit is used to fill the vacated bit positions. In other words, if the number is positive, 0 is used, and if the number is negative, 1 is used.
The right-shift operator causes the bit pattern in *`shift-expression`* to be shifted to the right by the number of positions specified by *`additive-expression`*. For unsigned numbers, the bit positions that have been vacated by the shift operation are zero-filled. For signed numbers, the sign bit is used to fill the vacated bit positions. In other words, if the number is positive, 0 is used, and if the number is negative, 1 is used.

> [!IMPORTANT]
> The result of a right-shift of a signed negative number is implementation-dependent. Although the Microsoft C++ compiler uses the sign bit to fill vacated bit positions, there is no guarantee that other implementations also do so.
Expand Down Expand Up @@ -158,9 +160,9 @@ int main() {
}
```

## Shifts and Promotions
## Shifts and promotions

The expressions on both sides of a shift operator must be integral types. Integral promotions are performed according to the rules described in [Standard Conversions](standard-conversions.md). The type of the result is the same as the type of the promoted *shift-expression*.
The expressions on both sides of a shift operator must be integral types. Integral promotions are performed according to the rules described in [Standard Conversions](standard-conversions.md). The type of the result is the same as the type of the promoted *`shift-expression`*.

In the following example, a variable of type **`char`** is promoted to an **`int`**.

Expand All @@ -181,9 +183,9 @@ int main() {
}
```

## Additional Details
## Details

The result of a shift operation is undefined if *additive-expression* is negative or if *additive-expression* is greater than or equal to the number of bits in the (promoted) *shift-expression*. No shift operation is performed if *additive-expression* is 0.
The result of a shift operation is undefined if *`additive-expression`* is negative or if *`additive-expression`* is greater than or equal to the number of bits in the (promoted) *`shift-expression`*. No shift operation takes place if *`additive-expression`* is 0.

```cpp
#include <iostream>
Expand Down Expand Up @@ -216,5 +218,5 @@ The value of `E1 >> E2` is `E1` right-shifted `E2` bit positions. If `E1` has an

## See also

[Expressions with Binary Operators](../cpp/expressions-with-binary-operators.md)<br/>
[C++ Built-in Operators, Precedence and Associativity](../cpp/cpp-built-in-operators-precedence-and-associativity.md)
[Expressions with binary operators](../cpp/expressions-with-binary-operators.md)<br/>
[C++ built-in operators, precedence, and associativity](../cpp/cpp-built-in-operators-precedence-and-associativity.md)
Binary file added docs/cpp/media/add-module.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/cpp/media/file-property-compile-as.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/cpp/media/language-switch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/cpp/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,8 @@ items:
href: ../cpp/modules-cpp.md
- name: module, import, export
href: ../cpp/import-export-module.md
- name: Named modules tutorial in C++
href: ../cpp/tutorial-named-modules-cpp.md
- name: Templates
items:
- name: Templates
Expand Down
Loading