Skip to content

Commit f29d163

Browse files
Taojunshen3836425+corob-msft@users.noreply.github.comopbld16TylerMSFTTylerMSFT
authored
2/15/2021 AM Publish (MicrosoftDocs#4100)
* Change __STDC__ documentation for 17.2 * Twhitney updateui (#4082) * update ui steps * simplify * fix formatting * try a note * formatting * bridge the note * edits * edits * acrolinx * Update docs/build/walkthrough-header-units.md Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com> Co-authored-by: Shannon Leavitt <V-SHLEAV@microsoft.com> * Fix link to CreateProcess function * Update exception-handling-x64.md * US1907300 - add md code escapes to code elements - PR9 * Address cpp-docs 3691, 3688, 3684, 3664 (MicrosoftDocs#4085) * [17.2p1] Add /scanDependencies option to docs (MicrosoftDocs#4059) * Add /scanDependencies option to docs * Acrolinx pass * Updates per review by Cameron * Consistency of command option formatting * Add IDE instructions * Tweaks per comments. * US1907300 - add md code escapes to code elements - PR7 (MicrosoftDocs#4076) * US1907300 - add md code escapes to code elements - PR7 * US1907300 - add md code escapes to code elements - PR7 * updates after review * updates after review * updates after review * updates after review * updates after review * US1907300 - add md code escapes to code elements - PR8 (MicrosoftDocs#4080) * US1907300 - add md code escapes to code elements - PR8 * updates after review * updates after review * updates after review * fix blocking issue * Address DD 1462641 (MicrosoftDocs#4086) * US1907300 - add md code escapes to code elements - PR9 * fix formatting issue * US1907300 - add md code escapes to code elements - PR10 * updates after review * updates after review * updates after review * updates after review * updates after review * Address cpp-docs 3694, 3696 * Update what-s-new-for-visual-cpp-in-visual-studio.md fix typo * add links (#4094) Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com> * Address cpp-docs 3694, 3696 (#4091) * Updates for cpp-docs 3700 3703 * Add op= to example * Add 3448,3482,3483,3540,3683 updates * Use existing media for CMake Targets View * US1907300 - add md code escapes to code elements - PR11 (MicrosoftDocs#4095) * US1907300 - add md code escapes to code elements - PR11 * updates after review * fix table syntax * trying to fix table rendering error * trying to fix table rendering error * trying to fix table rendering error * update after review Co-authored-by: 3836425+corob-msft@users.noreply.github.com <corob@microsoft.com> Co-authored-by: opbld16 <opbld16@microsoft.com> Co-authored-by: Tyler Whitney <TylerMSFT@users.noreply.github.com> Co-authored-by: TylerMSFT <Tyler.Whitney@microsoft.com> Co-authored-by: Shannon Leavitt <V-SHLEAV@microsoft.com> Co-authored-by: ishchukin <78567572+ishchukin@users.noreply.github.com> Co-authored-by: p4yl0ad <57832389+p4yl0ad@users.noreply.github.com> Co-authored-by: opbld17 <opbld17@microsoft.com> Co-authored-by: Craig Casey <17149610+craigcaseyMSFT@users.noreply.github.com> Co-authored-by: PRMerger9 <prmrgr9@microsoft.com> Co-authored-by: opbld15 <opbld15@microsoft.com> Co-authored-by: Dennis Rea <v-denrea@microsoft.com> Co-authored-by: jason <drvoss@gmail.com> Co-authored-by: Linda Spiller <93278958+LJSpiller@users.noreply.github.com>
1 parent 292c454 commit f29d163

22 files changed

+1184
-1160
lines changed

docs/assembler/inline/masm-macro-directives-in-inline-assembly.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ ms.assetid: 83643a09-1699-40a8-8ef2-13502bc4ac2c
99

1010
**Microsoft Specific**
1111

12-
The inline assembler is not a macro assembler. You cannot use MASM macro directives (**MACRO**, `REPT`, **IRC**, `IRP`, and `ENDM`) or macro operators (**<>**, **!**, **&**, `%`, and `.TYPE`). An **`__asm`** block can use C preprocessor directives, however. See [Using C or C++ in __asm Blocks](../../assembler/inline/using-c-or-cpp-in-asm-blocks.md) for more information.
12+
The inline assembler isn't a macro assembler. You can't use MASM macro directives (`MACRO`, `REPT`, `IRC`, `IRP`, and `ENDM`) or macro operators (**`<>`**, **`!`**, **`&`**, **`%`**, and `.TYPE`). An **`__asm`** block can use C preprocessor directives, however. See [Using C or C++ in `__asm` blocks](../../assembler/inline/using-c-or-cpp-in-asm-blocks.md) for more information.
1313

1414
**END Microsoft Specific**
1515

1616
## See also
1717

18-
[Using Assembly Language in __asm Blocks](../../assembler/inline/using-assembly-language-in-asm-blocks.md)<br/>
18+
[Using assembly language in `__asm` blocks](../../assembler/inline/using-assembly-language-in-asm-blocks.md)

docs/assembler/inline/writing-functions-with-inline-assembly.md

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,46 @@
11
---
2-
description: "Learn more about: Writing Functions with Inline Assembly"
3-
title: "Writing Functions with Inline Assembly"
4-
ms.date: "08/30/2018"
2+
description: "Learn more about: Writing functions with inline assembly"
3+
title: "Writing functions with inline assembly"
4+
ms.date: 02/11/2022
55
helpviewer_keywords: ["functions [C++], inline assembly", "inline assembly [C++], writing functions", "assembler [C++], writing functions", "__asm keyword [C++], in functions"]
66
ms.assetid: b5df8a04-fdc7-4622-8c9e-e4b618927497
77
---
8-
# Writing Functions with Inline Assembly
8+
# Writing functions with inline assembly
99

1010
**Microsoft Specific**
1111

12-
If you write a function with inline assembly code, it's easy to pass arguments to the function and return a value from it. The following examples compare a function first written for a separate assembler and then rewritten for the inline assembler. The function, called `power2`, receives two parameters, multiplying the first parameter by 2 to the power of the second parameter. Written for a separate assembler, the function might look like this:
12+
> [!NOTE]
13+
> Inline assembly is only available for x86 targets. For similar functionality in x64 or ARM64 code, use [compiler intrinsics](../../intrinsics/compiler-intrinsics.md).
14+
15+
If you write a function with inline assembly code, it's easy to pass arguments to the function and return a value from it. The following examples compare a function first written for a separate assembler and then rewritten for the inline assembler. The function, called `power2`, receives two parameters, multiplying the first parameter by 2 to the power of the second parameter. As a separate assembler file, the function might look like this:
1316

1417
```asm
15-
; POWER.ASM
16-
; Compute the power of an integer
17-
;
18-
PUBLIC _power2
19-
_TEXT SEGMENT WORD PUBLIC 'CODE'
18+
; power2.asm
19+
; x86 code for C interop
20+
; Command line: ml /c /Cx /W3 /WX power2.asm
21+
.686P
22+
.XMM
23+
.MODEL flat
24+
25+
PUBLIC _power2
26+
; int power2(int num, int power);
27+
; computes num x 2^power
28+
_TEXT SEGMENT
2029
_power2 PROC
21-
22-
push ebp ; Save EBP
23-
mov ebp, esp ; Move ESP into EBP so we can refer
24-
; to arguments on the stack
25-
mov eax, [ebp+4] ; Get first argument
26-
mov ecx, [ebp+6] ; Get second argument
27-
shl eax, cl ; EAX = EAX * ( 2 ^ CL )
28-
pop ebp ; Restore EBP
29-
ret ; Return with sum in EAX
30-
30+
push ebp ; save EBP
31+
mov ebp, esp ; Move ESP into EBP so we can refer
32+
; to arguments on the stack
33+
mov eax, [ebp+8] ; load first argument
34+
mov ecx, [ebp+12] ; load second argument
35+
shl eax, cl ; compute result in EAX
36+
pop ebp ; restore EBP
37+
ret
3138
_power2 ENDP
3239
_TEXT ENDS
33-
END
40+
END
3441
```
3542

36-
Since it's written for a separate assembler, the function requires a separate source file and assembly and link steps. C and C++ function arguments are usually passed on the stack, so this version of the `power2` function accesses its arguments by their positions on the stack. (Note that the **MODEL** directive, available in MASM and some other assemblers, also allows you to access stack arguments and local stack variables by name.)
43+
Since it's written as a separate assembler file, the function requires separate assembly and link steps. C and C++ function arguments are usually passed on the stack, so this version of the `power2` function accesses its arguments by their positions on the stack. (The **`MODEL`** directive, available in MASM and some other assemblers, also allows you to access stack arguments and local stack variables by name.)
3744

3845
## Example
3946

@@ -67,10 +74,10 @@ int power2( int num, int power )
6774
6875
The inline version of the `power2` function refers to its arguments by name and appears in the same source file as the rest of the program. This version also requires fewer assembly instructions.
6976
70-
Because the inline version of `power2` doesn't execute a C **`return`** statement, it causes a harmless warning if you compile at warning level 2 or higher. The function does return a value, but the compiler cannot tell that in the absence of a **`return`** statement. You can use [#pragma warning](../../preprocessor/warning.md) to disable the generation of this warning.
77+
Because the inline version of `power2` doesn't execute a C **`return`** statement, it causes a harmless warning if you compile at warning level 2 or higher. The function does return a value, but the compiler can't tell it does in the absence of a **`return`** statement. You can use [`#pragma warning`](../../preprocessor/warning.md) to disable the generation of this warning.
7178
7279
**END Microsoft Specific**
7380
7481
## See also
7582
76-
[Using C or C++ in __asm Blocks](../../assembler/inline/using-c-or-cpp-in-asm-blocks.md)<br/>
83+
[Using C or C++ in `__asm` Blocks](../../assembler/inline/using-c-or-cpp-in-asm-blocks.md)

docs/build/cmake-projects-in-visual-studio.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "CMake projects in Visual Studio"
33
description: "How to create and build C++ projects using CMake in Visual Studio."
4-
ms.date: 12/15/2021
4+
ms.date: 02/14/2022
55
helpviewer_keywords: ["CMake in Visual C++"]
66
ms.assetid: 444d50df-215e-4d31-933a-b41841f186f8
77
---
@@ -41,9 +41,9 @@ When you **open a folder** containing a *`CMakeLists.txt`* file, the following t
4141
> [!NOTE]
4242
> Starting in Visual Studio 2022 version 17.1 Preview 2, if your folder doesn't contain a root `CMakeLists.txt` you'll be prompted whether you'd like to enable CMake integration or not. For more information, see [CMake partial activation](#cmake-partial-activation).
4343
44-
Once CMake cache generation has succeeded, you can also view your projects organized logically by targets. Choose **Targets view** from the dropdown in the **Solution Explorer** toolbar:
44+
Once CMake cache generation has succeeded, you can also view your projects organized logically by targets. Choose the **Select View** button on the **Solution Explorer** toolbar. From the list in **Solution Explorer - Views**, select **CMake Targets View** and press **Enter** to open the targets view:
4545

46-
![CMake targets view button.](media/cmake-targets-view.png)
46+
:::image type="content" source="media/cmake-targets-view2.png" alt-text="Screenshot of the Solution Explorer Views window with the C Make Targets View highlighted.":::
4747

4848
Choose the **Show All Files** button at the top of **Solution Explorer** to see all the CMake-generated output in the *`out/build/<config>`* folders.
4949

@@ -90,7 +90,7 @@ You can also disable all CMake cache notifications (gold bars) by deselecting **
9090

9191
If you need more information about the state of the CMake cache to diagnose a problem, open the **Project** main menu or the *`CMakeLists.txt`* context menu in **Solution Explorer** to run one of these commands:
9292

93-
- **View CMakeCache.txt** opens the *`CMakeCache.txt`* file from the build directory in the editor. Any edits you make here to *`CMakeCache.txt`* are wiped out if you clean the cache. To make changes that persist after you clean the cache, see [Customize CMake settings](customize-cmake-settings.md) or [Configure and Build with CMake Presets](cmake-presets-vs.md).
93+
- **View CMakeCache.txt** opens the *`CMakeCache.txt`* file from the build directory in the editor. Any edits you make here to *`CMakeCache.txt`* are wiped out if you clean the cache. To make changes that persist after you clean the cache, see [Customize CMake settings](customize-cmake-settings.md) or [Configure and build with CMake Presets](cmake-presets-vs.md).
9494

9595
- **Delete Cache and Reconfigure** deletes the build directory and reconfigures from a clean cache.
9696

@@ -149,7 +149,7 @@ Visual Studio allows you to debug a process running on a remote Linux system or
149149

150150
## <a name="cmake-partial-activation"></a> CMake partial activation
151151

152-
Starting in Visual Studio 2022 version 17.1 Preview 2, CMake functionality won't be enabled automatically if your root folder doesn't contain a `CMakeLists.txt` file. Instead, a dialog will prompt you on whether you'd like to enable CMake functionality for your project. If you decline, CMake cache generation won't start and CMake configurations (from `CMakeSettings.json` or `CMakePresets.json`) won't appear in the configuration dropdown. If you accept, you'll be taken to a workspace-level configuration file, `CMakeWorkspaceSettings.json` (stored in the `.vs` directory), to specify the folders you'd like to enable CMake for. (These folders contain your root `CMakeLists.txt` files).
152+
In Visual Studio 2022 version 17.1 and later, CMake functionality won't be enabled automatically if your root folder doesn't contain a `CMakeLists.txt` file. Instead, a dialog will prompt you on whether you'd like to enable CMake functionality for your project. If you decline, CMake cache generation won't start and CMake configurations (from `CMakeSettings.json` or `CMakePresets.json`) won't appear in the configuration dropdown. If you accept, you'll be taken to a workspace-level configuration file, `CMakeWorkspaceSettings.json` (stored in the `.vs` directory), to specify the folders you'd like to enable CMake for. (These folders contain your root `CMakeLists.txt` files).
153153

154154
The accepted properties are:
155155

@@ -197,7 +197,7 @@ As soon as you save the file, the configuration step automatically runs again an
197197

198198
### Language services for CMake
199199

200-
Language services for CMake are available in Visual Studio 2019 version 16.5 or later. Code navigation features like Go To Definition, Peek Definition, and Find All References are supported for CMake variables, functions, and targets in CMake script files. For more information, see [Code Navigation for CMake Scripts](https://devblogs.microsoft.com/cppblog/code-navigation-for-cmake-scripts/).
200+
Language services for CMake are available in Visual Studio 2019 version 16.5 or later. It supports code navigation features like Go To Definition, Peek Definition, and Find All References for CMake variables, functions, and targets in CMake script files. For more information, see [Code Navigation for CMake Scripts](https://devblogs.microsoft.com/cppblog/code-navigation-for-cmake-scripts/).
201201

202202
![Find All References on a CMake variable, target, or function.](media/cmake-find-all-refs.png)
203203

0 commit comments

Comments
 (0)