Skip to content

Commit d74f100

Browse files
authored
Merge pull request #5837 from cdpark/refresh-vs-articles-3
Feature 363608: Q&M: Content Freshness for C++ Content -- batch 3
2 parents 6c0b17a + 807037f commit d74f100

6 files changed

+46
-52
lines changed
15.6 KB
Loading
Loading
Loading

docs/build/toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ items:
99
- name: Set C++ compiler and build properties in Visual Studio
1010
expanded: false
1111
items:
12-
- name: Set C++ compiler and build properties in Visual Studio
12+
- name: Set C++ compiler and build properties
1313
href: ../build/working-with-project-properties.md
1414
- name: Share or reuse Visual Studio project settings
1515
href: ../build/create-reusable-property-configurations.md

docs/build/working-with-project-properties.md

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
---
2-
title: "Set C++ compiler and build properties in Visual Studio"
2+
title: "Set C++ Compiler and Build Properties in Visual Studio"
33
description: "Use the Visual Studio IDE to change C++ compiler and linker options and other build settings."
4-
ms.date: "07/17/2019"
4+
ms.date: 03/19/2025
5+
ms.topic: concept-article
56
helpviewer_keywords: ["project properties [C++], modifying", "properties [C++]", "Visual C++ projects, properties", "projects [C++], properties"]
67
---
78
# Set compiler and build properties
89

9-
In the IDE, properties expose the information needed to build a project. This information includes the application name, extension (such as DLL, LIB, EXE), compiler options, linker options, debugger settings, custom build steps, and many other things. Typically, you use *property pages* to view and modify these properties. To access the property pages, choose **Project** > **_project-name_ Properties** from the main menu, or right-click on the project node in **Solution Explorer** and choose **Properties**.
10+
In the Visual Studio IDE, you can view and edit the properties needed to compile and build a project. This information includes the application name, extension (such as DLL, LIB, EXE), compiler options, linker options, debugger settings, and custom build steps.
11+
12+
You can view and modify these properties by using *property pages*. To access the property pages, choose **Project** > **_project-name_ Properties** from the main menu, or right-click on the project node in **Solution Explorer** and choose **Properties**.
1013

1114
## Default properties
1215

13-
When you create a project, the system assigns values for various properties. The defaults vary somewhat depending on the kind of project and what options you choose in the app wizard. For example, an ATL project has properties related to MIDL files, but these properties are absent in a basic console application. The default properties are shown in the General pane in the Property Pages:
16+
When you create a project, the system assigns values for various properties. The defaults vary somewhat depending on the kind of project and what options you choose in the app wizard. For example, an Active Template Library (ATL) project has properties related to Microsoft Interface Definition Language (MIDL) files, but these properties are absent in a basic console application. The default properties are shown in the Advanced pane in the **Property Pages** window:
1417

15-
:::image type="complex" source="media/visual-c---project-defaults.png" alt-text="Screenshot of the Visual Studio project properties dialog.":::
16-
The General page is open. The Project Defaults section is highlighted, which includes Configuration Type set to Application (.exe), use of MFC set to Use standard Windows libraries, Character set is Unicode, Common Language Runtime Support is set to No Common Language Runtime Support, Whole Program optimization is set to No Whole Program Optimization, and Windows Store APP support is set to No.
17-
:::image-end:::
18+
:::image type="content" source="media/visual-c---project-defaults.png" alt-text="Screenshot of the Visual Studio project properties dialog box with the Advanced pane selected." lightbox="media/visual-c---project-defaults.png":::
1819

19-
## Applying properties to build configurations and target platforms
20+
## Apply properties to build configurations and target platforms
2021

2122
Some properties, such as the application name, apply to all build variations and target platforms, whether it's a debug or release build. But most properties are configuration-dependent. To generate the correct code, the compiler has to know both the specific platform the program runs on and which specific compiler options to use. So when you set a property, it's important to pay attention to which configuration and platform the new value should apply to. Should it apply only to Debug Win32 builds, or should it also apply to Debug ARM64 and Debug x64? For example, the **Optimization** property, by default, is set to **Maximize Speed (/O2)** in a Release configuration, but is disabled in the Debug configuration.
2223

@@ -28,11 +29,11 @@ The page is open to C/C++, Optimization. The Optimization setting is set to Disa
2829

2930
The following illustration shows the same project property page, but the configuration has been changed to Release. Note the different value for the Optimization property. Also note that the active configuration is still Debug. You can set properties for any configuration here; it doesn't have to be the active one.
3031

31-
:::image type="content" source="media/visual-c---property-pages-showing-release-config.png" alt-text="Screenshot of the Visual Studio project Property Pages dialog. The Configuration dropdown is called out and is set to Release. The C/C++ > Optimization > Optimization setting is set to Maximize Speed (/O2).":::
32+
:::image type="content" source="media/visual-c---property-pages-showing-release-config.png" alt-text="Screenshot of the Visual Studio project Property Pages dialog. The Configuration dropdown is called out and is set to Release. The optimization setting is set to Maximize Speed slash O2.":::
3233

3334
## Target platforms
3435

35-
*Target platform* refers to the kind of device and operating system that the executable will run on. You can build a project for more than one platform. The available target platforms for C++ projects depend on the kind of project. They include but aren't limited to Win32, x64, ARM, ARM64, Android, and iOS. The **x86** target platform that you might see in **Configuration Manager** is identical to **Win32** in native C++ projects. Win32 means 32-bit Windows and **x64** means 64-bit Windows. For more information about these two platforms, see [Running 32-bit applications](/windows/win32/WinProg64/running-32-bit-applications).
36+
*Target platform* refers to the kind of device and operating system that the executable runs on. You can build a project for more than one platform. The available target platforms for C++ projects depend on the kind of project. They include but aren't limited to Win32, x64, ARM, ARM64, Android, and iOS. The **x86** target platform that you might see in **Configuration Manager** is identical to **Win32** in native C++ projects. Win32 means 32-bit Windows and **x64** means 64-bit Windows. For more information about these two platforms, see [Running 32-bit applications](/windows/win32/WinProg64/running-32-bit-applications).
3637

3738
The **Any CPU** target platform value that you might see in **Configuration Manager** has no effect on native C++ projects. It's only relevant for C++/CLI and other .NET project types. For more information, see [`/CLRIMAGETYPE` (Specify Type of CLR Image)](reference/clrimagetype-specify-type-of-clr-image.md).
3839

@@ -51,7 +52,7 @@ The **Property Pages** dialog box shows only the property pages that are relevan
5152

5253
## Directory and path values
5354

54-
MSBuild supports the use of compile-time constants for certain string values, such as include directories and paths, called *macros*. A macro can refer to a value that's defined by Visual Studio or the MSBuild system, or to a user-defined value. Macros look like `$(macro-name)` or `%(item-macro-name)`. They're exposed in the property pages, where you can refer to and modify them by using the [Property Editor](#property_editor). Use macros instead of hard-coded values such as directory paths. Macros make it easier to share property settings between machines and between versions of Visual Studio. And, you can better ensure that your project settings participate correctly in [property inheritance](project-property-inheritance.md).
55+
MSBuild supports the use of compile-time constants for certain string values, such as include directories and paths, called *macros*. A macro can refer to a value that's defined by Visual Studio or the MSBuild system, or to a user-defined value. Macros look like `$(macro-name)` or `%(item-macro-name)`. They're exposed in the property pages, where you can refer to and modify them by using the [Property Editor](#property_editor). Use macros instead of hard-coded values such as directory paths. Macros make it easier to share property settings between machines and between versions of Visual Studio. You can also better ensure that your project settings participate correctly in [property inheritance](project-property-inheritance.md).
5556

5657
The following illustration shows the property pages for a Visual Studio C++ project. In the left pane, the **VC++ Directories** *rule* is selected, and the right pane lists the properties that are associated with that rule. The property values are often macros, such as `$(VC_SourcePath)`:
5758

@@ -63,21 +64,21 @@ You can use the [Property Editor](#property_editor) to view the values of all av
6364

6465
### Predefined macros
6566

66-
- **Global macros**:\
67+
- **Global macros**\
6768
Global macros apply to all items in a project configuration. A global macro has the syntax `$(name)`. An example of a global macro is `$(VCInstallDir)`, which stores the root directory of your Visual Studio installation. A global macro corresponds to a `PropertyGroup` in MSBuild.
6869

6970
- **Item macros**\
70-
Item macros have the syntax `%(name)`. For a file, an item macro applies only to that file—for example, you can use `%(AdditionalIncludeDirectories)` to specify include directories that apply only to a particular file. This kind of item macro corresponds to an `ItemGroup` metadata in MSBuild. When used in the context of a project configuration, an item macro applies to all files of a certain type. For example, the C/C++ **Preprocessor Definitions** configuration property can take a `%(PreprocessorDefinitions)` item macro that applies to all .cpp files in the project. This kind of item macro corresponds to an `ItemDefinitionGroup` metadata in MSBuild. For more information, see [Item Definitions](/visualstudio/msbuild/item-definitions).
71+
Item macros have the syntax `%(name)`. For a file, an item macro applies only to that file. For example, you can use `%(AdditionalIncludeDirectories)` to specify include directories that apply only to a particular file. This kind of item macro corresponds to an `ItemGroup` metadata in MSBuild. When used in the context of a project configuration, an item macro applies to all files of a certain type. For example, the C/C++ **Preprocessor Definitions** configuration property can take a `%(PreprocessorDefinitions)` item macro that applies to all .cpp files in the project. This kind of item macro corresponds to an `ItemDefinitionGroup` metadata in MSBuild. For more information, see [Item definitions](/visualstudio/msbuild/item-definitions).
7172

7273
### User-defined macros
7374

74-
You can create *user-defined macros* to use as variables in project builds. For example, you could create a user-defined macro that provides a value to a custom build step or a custom build tool. A user-defined macro is a name/value pair. In a project file, use the `$(name)` notation to access the value.
75+
You can create *user-defined macros* to use as variables in project builds. For example, you could create a user-defined macro that provides a value to a custom build step or a custom build tool. A user-defined macro is a name-value pair. In a project file, use the `$(name)` notation to access the value.
7576

7677
A user-defined macro is stored in a property sheet. If your project doesn't already contain a property sheet, you can create one by following the steps under [Share or reuse Visual Studio project settings](create-reusable-property-configurations.md).
7778

7879
#### To create a user-defined macro
7980

80-
1. Open the **Property Manager** window. (On the menu bar, choose **View** > **Property Manager** or **View** > **Other Windows** > **Property Manager**.) Open the shortcut menu for a property sheet (its name ends in *`.user`*) and then choose **Properties**. The **Property Pages** dialog box for that property sheet opens.
81+
1. Open the **Property Manager** window. On the menu bar, select **View** > **Other Windows** > **Property Manager**. Open the shortcut menu for a property sheet (its name ends in *`.user`*) and then choose **Properties**. The **Property Pages** dialog box for that property sheet opens.
8182

8283
1. In the left pane of the dialog box, select **User Macros**. In the right pane, choose the **Add Macro** button to open the **Add User Macro** dialog box.
8384

@@ -99,20 +100,17 @@ The property editor for Include Directories is open. The evaluated value is disp
99100

100101
## Add an include directory to the set of default directories
101102

102-
When you add an include directory to a project, it's important not to override all the default directories. The correct way to add a directory is to append the new path, for example "`C:\MyNewIncludeDir\`", and then to Append the **`$(IncludePath)`** macro to the property value.
103+
When you add an include directory to a project, it's important not to override all the default directories. The correct way to add a directory is to append the new path, for example `C:\MyNewIncludeDir\`, and then to append the `$(IncludePath)` macro to the property value.
103104

104105
## Quickly browse and search all properties
105106

106107
The **All Options** property page (under the **Configuration Properties** > **C/C++** node in the **Property Pages** dialog box) provides a quick way to browse and search the properties that are available in the current context. It has a special search box and a simple syntax to help you filter results:
107108

108-
No prefix:\
109-
Search in property names only (case-insensitive substring).
109+
- No prefix: Search in property names only (case-insensitive substring).
110110

111-
'`/`' or '`-`':\
112-
Search only in compiler switches (case-insensitive prefix)
111+
- '`/`' or '`-`': Search only in compiler switches (case-insensitive prefix).
113112

114-
`v`:\
115-
Search only in values (case-insensitive substring).
113+
- `v`: Search only in values (case-insensitive substring).
116114

117115
## Set environment variables for a build
118116

@@ -124,19 +122,14 @@ In the left pane of the project's **Property Pages** dialog box, expand **Config
124122

125123
In the right pane, modify the **Environment** or **Merge Environment** project settings and then choose the **OK** button.
126124

127-
## In this section
128-
129-
[Share or reuse Visual Studio project settings](create-reusable-property-configurations.md)\
130-
How to create a *`.props`* file with custom build settings that can be shared or reused.
131-
132-
[Project property inheritance](project-property-inheritance.md)\
133-
Describes the order of evaluation for the *`.props`*, *`.targets`*, *`.vcxproj`* files, and environment variables in the build process.
125+
## Articles in this section
134126

135-
[Modify properties and targets without changing the project file](modify-project-properties-without-changing-project-file.md)\
136-
How to create temporary build settings without having to modify a project file.
127+
- [Share or reuse Visual Studio project settings](create-reusable-property-configurations.md)
128+
- [Property inheritance in Visual Studio projects](project-property-inheritance.md)
129+
- [Modify C++ project properties and targets without changing the project file](modify-project-properties-without-changing-project-file.md)
137130

138131
## See also
139132

140-
[Visual Studio Projects - C++](creating-and-managing-visual-cpp-projects.md)\
141-
[`.vcxproj` and `.props` file structure](reference/vcxproj-file-structure.md)\
142-
[Property page XML files](reference/property-page-xml-files.md)
133+
- [Visual Studio projects - C++](creating-and-managing-visual-cpp-projects.md)
134+
- [`.vcxproj` and `.props` file structure](reference/vcxproj-file-structure.md)
135+
- [Property Page XML rule files](reference/property-page-xml-files.md)

0 commit comments

Comments
 (0)