Skip to content

Resolve syncing conflicts from FromPrivateLiveToMaster to main #4436

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 20 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions docs/build/building-on-the-command-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ The Start menu folder and shortcut names vary depending on the installed version

For an even faster way to open a developer command prompt, enter *developer command prompt* in the desktop search box. Then choose the result you want.

> [!NOTE]
> By default, the current working directory in a developer command prompt is the root of your Visual Studio installation in the Program Files directory. This isn't an appropriate location for your code and projects. Change the current working directory to another location before you create a project. The IDE creates projects in your user directory, typically in *%USERPROFILE%\\source\\repos*.

## <a name="developer_command_file_locations"></a> Developer command file locations

If you prefer to set the build environment in an existing command prompt window, you can use one of the command files created by the installer. We recommend you set the environment in a new command prompt window. We don't recommend you later switch environments in the same command window.
Expand Down
2 changes: 1 addition & 1 deletion docs/build/cmakesettings-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ If you don't define the `"type"`, the `"STRING"` type is assumed by default.

## <a name="environments"></a> Environments

An *environment* encapsulates the environment variables set in the process that Visual Studio uses to invoke CMake. For MSVC projects, it captures the variables set in a [developer command prompt](building-on-the-command-line.md) for a specific platform. For example, the `msvc_x64_x64` environment is the same as running the **Developer Command Prompt for VS 2017** or **Developer Command Prompt for VS 2019** with the **-arch=amd64 -host_arch=amd64** arguments. You can use the `env.{<variable_name>}` syntax in *`CMakeSettings.json`* to reference the individual environment variables, for example to construct paths to folders. The following predefined environments are provided:
An *environment* encapsulates the environment variables set in the process that Visual Studio uses to invoke CMake. For MSVC projects, it captures the variables set in a [developer command prompt](building-on-the-command-line.md) for a specific platform. For example, the `msvc_x64_x64` environment is the same as running the **Developer Command Prompt for VS {version}** with the **-arch=amd64 -host_arch=amd64** arguments. You can use the `env.{<variable_name>}` syntax in *`CMakeSettings.json`* to reference the individual environment variables, for example to construct paths to folders. The following predefined environments are provided:

- `linux_arm`: Target ARM Linux remotely.
- `linux_x64`: Target x64 Linux remotely.
Expand Down
2 changes: 1 addition & 1 deletion docs/build/reference/netmodule-files-as-linker-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ link.exe accepts MSIL *`.obj`* and *`.netmodule`* files as input. The output fil

The linker must be passed the *`.obj`* file from the C++ compilation that created the *`.netmodule`*. Passing in a *`.netmodule`* is no longer supported because the **/clr:pure** and **/clr:safe** compiler options are deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017 and later.

For information on how to invoke the linker from the command line, see [Linker command-line syntax](linking.md), [Use the MSVC toolset from the command line](../building-on-the-command-line.md), and [Use the MSVC toolset from the command line](../building-on-the-command-line.md).
For information on how to invoke the linker from the command line, see [Linker command-line syntax](linking.md) and [Use the MSVC toolset from the command line](../building-on-the-command-line.md).

Passing a *`.netmodule`* or *`.dll`* file to the linker that was compiled by the MSVC compiler with **/clr** can result in a linker error. For more information, see [Choosing the format of .netmodule input files](choosing-the-format-of-netmodule-input-files.md).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ To enable compilation for C++/CLI, you must use the [/clr](reference/clr-common-

Administrator credentials may be required to successfully compile the code, depending on the computer's operating system and configuration. To run the command prompt window as an administrator, right-click to open the shortcut menu for the command prompt and then choose **More** > **Run as administrator**.

1. Change the current working directory in the command prompt window to a directory you can write to, such as your Documents directory.

1. At the command prompt, enter `notepad basicclr.cpp`.

Choose **Yes** when you're prompted to create a file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ To enable compilation for C++/CX, you must use the [/ZW](reference/zw-windows-ru

#### To compile a C++/CX application on the command line

1. Open a **Developer Command Prompt** window. (On the **Start** window, open **Apps**. Open the **Visual Studio Tools** folder under your version of Visual Studio, and then choose the **Developer Command Prompt** shortcut.) For more information about how to open a Developer Command Prompt window, see [Use the MSVC toolset from the command line](building-on-the-command-line.md).
1. Open a **Developer Command Prompt** window. For specific instructions, see [To open a developer command prompt window](building-on-the-command-line.md#developer_command_prompt).

Administrator credentials may be required to successfully compile the code, depending on the computer's operating system and configuration. To run the Command Prompt window as an administrator, open the shortcut menu for **Developer Command Prompt** and then choose **Run as administrator**.
Administrator credentials may be required to successfully compile the code, depending on the computer's operating system and configuration. To run the command prompt window as an administrator, right-click to open the shortcut menu for the command prompt and then choose **More** > **Run as administrator**.

1. Change the current working directory in the command prompt window to a directory you can write to, such as your Documents directory.

1. At the command prompt, enter **notepad basiccx.cpp**.

Expand Down
24 changes: 13 additions & 11 deletions docs/ide/walkthrough-working-with-projects-and-solutions-cpp.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: Walkthrough: Working with Projects and Solutions (C++)"
title: "Walkthrough: Working with Projects and Solutions (C++)"
ms.date: 10/27/2021
ms.date: 02/23/2023
helpviewer_keywords: ["solutions [C++]", "projects [C++], about projects", "projects [C++]", "solutions [C++], about solutions"]
ms.assetid: 93a3f290-e294-46e3-876e-e3084d9ae833
---
Expand All @@ -19,7 +19,7 @@ It helps if you understand the fundamentals of the C++ language, and know what a

## Create a project

To create a project, first choose a project-type template. For each project type, Visual Studio sets compiler settings and—depending on the type—generates starter code that you can modify later. The following steps vary depending on which version of Visual Studio you are using. To see the documentation for your preferred version of Visual Studio, use the **Version** selector control. It's found at the top of the table of contents on this page.
To create a project, first choose a project-type template. For each project type, Visual Studio sets compiler settings and—depending on the type—generates starter code that you can modify later. The following steps vary depending on which version of Visual Studio you're using. To see the documentation for your preferred version of Visual Studio, use the **Version** selector control. It's found at the top of the table of contents on this page.

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

Expand Down Expand Up @@ -49,7 +49,7 @@ To create a project, first choose a project-type template. For each project type

1. In the left pane of the **New Project** dialog box, expand **Installed** and select **Visual C++**, if it isn't open already.

1. In the list of installed templates in the center pane, select **Windows Console Application**.
1. In the list of installed templates in the center pane, select **Console App**.

1. Enter a name for the project in the **Name** box. For this example, enter *Game*.

Expand Down Expand Up @@ -79,7 +79,11 @@ To create a project, first choose a project-type template. For each project type

When you create a project, Visual Studio puts the project in a solution. By default, the solution has the same name as the project. You can change the name in the **Solution name** box, but for this example, keep the default name.

1. Choose the **OK** button to create the project.
1. Choose the **OK** button to dismiss the **New Project** dialog and start the **Win32 Application Wizard**.

1. In the wizard, choose the **Next** button. On the **Application Settings** page, under **Additional options**, clear the **Precompiled header** check box.

1. Choose the **Finish** button to create the project.

Visual Studio creates your new solution and project files, and opens the editor for the Game.cpp source code file it generated.

Expand All @@ -99,7 +103,7 @@ This part of the walkthrough shows how to add a class to the project. When you a

1. In the **Add Class** dialog, enter *Cardgame* in the **Class Name** box. Don't modify the default file names and settings. Choose the **OK** button.

Visual Studio creates new files and adds them to your project. You can see them in the **Solution Explorer** window. The Cardgame.h and Cardgame.cpp files are opened in the editor.
Visual Studio creates new files and adds them to your project. You can see them in the **Solution Explorer** window. Visual Studio opens the Cardgame.h and Cardgame.cpp files in the editor.

1. Edit the Cardgame.h file, and make these changes:

Expand All @@ -120,12 +124,12 @@ This part of the walkthrough shows how to add a class to the project. When you a
<!--[!code-cpp[NVC_Walkthrough_Working_With_Projects#101](../ide/codesnippet/CPP/walkthrough-working-with-projects-and-solutions-cpp_2.h)]-->
`Cardgame(int players);`

- After the default destructor, add an inline declaration for a `static int` member function named *GetParticipants* that takes no parameters and returns the `totalParticipants` value.
- After the default destructor, add an inline declaration for a `static int` member function named `GetParticipants` that takes no parameters and returns the `totalParticipants` value.

<!--[!code-cpp[NVC_Walkthrough_Working_With_Projects#102](../ide/codesnippet/CPP/walkthrough-working-with-projects-and-solutions-cpp_3.h)]-->
`static int GetParticipants() { return totalParticipants; }`

The Cardgame.h file should resemble the code below after you change it:
The Cardgame.h file should resemble this code after you change it:

<!--[!code-cpp[NVC_Walkthrough_Working_With_Projects#103](../ide/codesnippet/CPP/walkthrough-working-with-projects-and-solutions-cpp_4.h)]-->

Expand All @@ -142,7 +146,7 @@ This part of the walkthrough shows how to add a class to the project. When you a
};
```

The line `#pragma once` tells the compiler to include the header file only one time. For more information, see [once](../preprocessor/once.md). For information about other C++ keywords in the header file above, see [class](../cpp/class-cpp.md), [int](../cpp/fundamental-types-cpp.md), [static](../cpp/storage-classes-cpp.md), and [public](../cpp/public-cpp.md).
The line `#pragma once` tells the compiler to include the header file only one time. For more information, see [`once`](../preprocessor/once.md). For information about other C++ keywords in the header file, see [`class`](../cpp/class-cpp.md), [`int`](../cpp/fundamental-types-cpp.md), [`static`](../cpp/storage-classes-cpp.md), and [`public`](../cpp/public-cpp.md).

1. Choose the **Cardgame.cpp** tab at the top of the editing pane to open it for editing.

Expand All @@ -151,7 +155,6 @@ This part of the walkthrough shows how to add a class to the project. When you a
<!--[!code-cpp[NVC_Walkthrough_Working_With_Projects#111](../ide/codesnippet/CPP/walkthrough-working-with-projects-and-solutions-cpp_5.cpp)]-->

```cpp
#include "pch.h" // remove this line in Visual Studio 2019
#include "Cardgame.h"
#include <iostream>

Expand All @@ -164,7 +167,7 @@ This part of the walkthrough shows how to add a class to the project. When you a
{
totalParticipants += players;
cout << players << " players have started a new game. There are now "
<< totalParticipants << " players in total." << endl;
<< totalParticipants << " players in total.\n";
}

Cardgame::~Cardgame()
Expand All @@ -189,7 +192,6 @@ Add some code to your app that tests the new functions.
// Game.cpp : Defines the entry point for the console application.
//

#include "pch.h" // remove this line in Visual Studio 2019
#include "Cardgame.h"
#include <iostream>

Expand Down