Skip to content

Commit 22029ab

Browse files
Albertyang0carsonRadtkeTylerMSFTJillGrant615prmerger-automator[bot]
authored
4/15/2025 AM Publish (#5873)
* docs for justification in pragma warning * docs for gsl::suppress * teach gsl::suppress("rule") instead of gsl::suppress(rule) * doc - portion of flag * acrolinx * related to #5230 - call out buffer fill behavior * edit * acrolinx/link fix * Confirm merge from FromPublicMasterBranch to main to sync with https://github.com/MicrosoftDocs/cpp-docs (branch main) (#5870) * vswprintf/_vswprintf_l return value description update. * Return value/Remarks sections update. * Behavior summary update. * Behavior summary update. * Merge pull request #5867 from MicrosoftDocs/main 4/10/2025 AM Publish * Update behavior description for `buffer` and `count` conditions The behavior is slightly different than stated. * Update return value behavior for valid buffer behave is different than written here. * Clarify vswprintf return values for count zero behavior is a little different for count = 0 case. * Update remarks and behavior summary sections The behavior in debug mode applies to all functions on this page, so made more prominent. * Fix NULL character formatting in documentation * 4/11/2025 AM Publish (#5869) * doc - portion of flag * acrolinx --------- Co-authored-by: TylerMSFT <[email protected]> Co-authored-by: Jill Grant <[email protected]> * Clarify vswprintf behavior when count is zero * Standardize 'null' to 'NULL' --------- Co-authored-by: Nikita Leontiev <[email protected]> Co-authored-by: Bo wen Yang <[email protected]> Co-authored-by: learn-build-service-prod[bot] <113403604+learn-build-service-prod[bot]@users.noreply.github.com> Co-authored-by: Learn Build Service GitHub App <Learn Build Service [email protected]> Co-authored-by: Tyler Whitney <[email protected]> Co-authored-by: Jill Grant <[email protected]> Co-authored-by: Courtney Wales <[email protected]> * Add Arm64 forceInterlockedFunctions option (#5822) * Learn Editor: Update compiler-options-listed-by-category.md * Learn Editor: Update compiler-options-listed-alphabetically.md * Learn Editor: Update force-interlocked-functions.md * Learn Editor: Update force-interlocked-functions.md * update Metadata * Update force-interlocked-functions.md with github id author name * Reorder compiler options in toc.yml to be alphabetical * Learn Editor: Update compiler-options-listed-alphabetically.md * Learn Editor: Update compiler-options-listed-by-category.md * Learn Editor: Update force-interlocked-functions.md * change article metadata * Learn Editor: Update force-interlocked-functions.md * Fix casing in toc.yml for forceInterlockedFunctions * Add 'items' section to toc.yml to revert previous change * Fix indentation in toc.yml file * Update metadata and improve documentation wording * Update metadata in force-interlocked-functions.md tidied up metdata * Fix typos and improve clarity in documentation * Update description for `/forceInterlockedFunctions` option * Clarify CPU capability/ runtime description in documentation * Update remark on Armv8.0 instructions * Remove unneeded template comments and update livelock remarks in documentation * Add "---" to metadata --------- Co-authored-by: Tyler Whitney <[email protected]> * address feedback * small edits --------- Co-authored-by: Carson Radtke <[email protected]> Co-authored-by: TylerMSFT <[email protected]> Co-authored-by: Jill Grant <[email protected]> Co-authored-by: prmerger-automator[bot] <40007230+prmerger-automator[bot]@users.noreply.github.com> Co-authored-by: learn-build-service-prod[bot] <113403604+learn-build-service-prod[bot]@users.noreply.github.com> Co-authored-by: Nikita Leontiev <[email protected]> Co-authored-by: Learn Build Service GitHub App <Learn Build Service [email protected]> Co-authored-by: Courtney Wales <[email protected]> Co-authored-by: Emily Bao <[email protected]> Co-authored-by: Stacy Chambers <[email protected]>
1 parent 94f094a commit 22029ab

11 files changed

+109
-42
lines changed

docs/build/reference/compiler-options-listed-alphabetically.md

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ This table contains an alphabetical list of compiler options. For a list of comp
6767
| [`/Fd`](fd-program-database-file-name.md) | Renames program database file. |
6868
| [`/Fe`](fe-name-exe-file.md) | Renames the executable file. |
6969
| [`/feature`](feature-arm64.md) | Enable architecture features.<sup>17.10</sup> |
70+
| [`/forceInterlockedFunctions`](force-interlocked-functions.md) | Dynamically selects between Armv8.0 load, store exclusive instructions or Armv8.1 LSE atomic instructions based on target CPU.<sup>17.14</sup> |
7071
| [`/FI<file>`](fi-name-forced-include-file.md) | Preprocesses the specified include file. |
7172
| [`/Fi`](fi-preprocess-output-file-name.md) | Specifies the preprocessed output file name. |
7273
| [`/Fm`](fm-name-mapfile.md) | Creates a mapfile. |
@@ -261,6 +262,7 @@ This table contains an alphabetical list of compiler options. For a list of comp
261262
| [`/ZW`](zw-windows-runtime-compilation.md) | Produces an output file to run on the Windows Runtime. |
262263

263264
<sup>17.10</sup> This option is available starting in Visual Studio 2022 version 17.10.
265+
<sup>17.14</sup> This option is available starting in Visual Studio 2022 version 17.14.
264266

265267
## See also
266268

docs/build/reference/compiler-options-listed-by-category.md

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ This article contains a categorical list of compiler options. For an alphabetica
4444
| [`/EHr`](eh-exception-handling-model.md) | Always generate `noexcept` runtime termination checks. |
4545
| [`/EHs`](eh-exception-handling-model.md) | Enable C++ exception handling (no SEH exceptions). |
4646
| [`/feature`](feature-arm64.md) | Enable architecture features.<sup>17.10</sup> |
47+
| [`/forceInterlockedFunctions`](force-interlocked-functions.md) | Dynamically selects between Armv8.0 load, store exclusive instructions or Armv8.1 LSE atomic instructions based on target CPU.<sup>17.14</sup> |
4748
| [`/fp:contract`](fp-specify-floating-point-behavior.md) | Consider floating-point contractions when generating code. |
4849
| [`/fp:except[-]`](fp-specify-floating-point-behavior.md) | Consider floating-point exceptions when generating code. |
4950
| [`/fp:fast`](fp-specify-floating-point-behavior.md) | "fast" floating-point model; results are less predictable. |
@@ -329,6 +330,7 @@ Experimental options may only be supported by certain versions of the compiler.
329330
| [`/Zg`](zg-generate-function-prototypes.md) | Removed in Visual Studio 2015. Generates function prototypes. |
330331

331332
<sup>17.10</sup> This option is available starting in Visual Studio 2022 version 17.10.
333+
<sup>17.14</sup> This option is available starting in Visual Studio 2022 version 17.14.
332334

333335
## See also
334336

Original file line numberDiff line numberDiff line change
@@ -1,51 +1,48 @@
11
---
22
description: "Learn more about: /constexpr (Control constexpr evaluation)"
33
title: "/constexpr (Control constexpr evaluation)"
4-
ms.date: "08/15/2017"
4+
ms.date: 04/14/2025
55
f1_keywords: ["/constexpr", "-constexpr"]
66
helpviewer_keywords: ["/constexpr control constexpr evaluation [C++]", "-constexpr control constexpr evaluation [C++]", "constexpr control constexpr evaluation [C++]"]
7-
ms.assetid: 76d56784-f5ad-401d-841d-09d1059e8b8c
87
---
98
# /constexpr (Control constexpr evaluation)
109

11-
Use the **/constexpr** compiler options to control parameters for **`constexpr`** evaluation at compile time.
10+
Use the **`/constexpr`** compiler options to control parameters for **`constexpr`** evaluation at compile time.
1211

1312
## Syntax
1413

15-
> **/constexpr:depth**<em>N</em>\
16-
> **/constexpr:backtrace**<em>N</em>\
17-
> **/constexpr:steps**<em>N</em>
14+
> `/constexpr:depth`<em>N</em>\
15+
> `/constexpr:backtrace`<em>N</em>\
16+
> `/constexpr:steps`<em>N</em>
1817
1918
## Arguments
2019

21-
**depth**<em>N</em>
20+
**`depth`**<em>N</em>\
2221
Limit the depth of recursive **`constexpr`** function invocation to *N* levels. The default is 512.
2322

24-
**backtrace**<em>N</em>
23+
**`backtrace`**<em>N</em>\
2524
Show up to *N* **`constexpr`** evaluations in diagnostics. The default is 10.
2625

27-
**steps**<em>N</em>
28-
Terminate **`constexpr`** evaluation after *N* steps. The default is 100,000.
26+
**`steps`**<em>N</em>\
27+
Terminate **`constexpr`** evaluation after *N* steps. The default is 100,000. A step refers to an individual computation taken towards evaluating the constant expression. Increasing the maximum number of steps might cause compilation to take longer in cases where compilation would otherwise fail.
2928

3029
## Remarks
3130

32-
The **/constexpr** compiler options control compile-time evaluation of **`constexpr`** expressions. Evaluation steps, recursion levels, and backtrace depth are controlled to prevent the compiler from spending too much time on **`constexpr`** evaluation. For more information on the **`constexpr`** language element, see [constexpr (C++)](../../cpp/constexpr-cpp.md).
31+
The **`/constexpr`** compiler options control compile-time evaluation of **`constexpr`** expressions. Evaluation steps, recursion levels, and backtrace depth are controlled to prevent the compiler from spending too much time on **`constexpr`** evaluation. For more information on the **`constexpr`** language element, see [`constexpr` (C++)](../../cpp/constexpr-cpp.md).
3332

34-
The **/constexpr** options are available beginning in Visual Studio 2015.
33+
The **`/constexpr`** flag is available beginning in Visual Studio 2015.
3534

3635
### To set this compiler option in the Visual Studio development environment
3736

3837
1. Open your project's **Property Pages** dialog box.
39-
4038
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
41-
42-
1. Enter any **/constexpr** compiler options in the **Additional Options** box. Choose **OK** or **Apply** to save your changes.
39+
1. Enter **/constexpr** compiler options in the **Additional Options** box. Choose **OK** to save your changes.
4340

4441
### To set this compiler option programmatically
4542

4643
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
4744

4845
## See also
4946

50-
[MSVC Compiler Options](compiler-options.md)<br/>
47+
[MSVC Compiler Options](compiler-options.md)\
5148
[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: "/forceInterlockedFunctions"
3+
description: "Learn more about /forceInterlockedFunctions"
4+
ms.date: 03/07/2025
5+
---
6+
# `/forceInterlockedFunctions`
7+
8+
Dynamically selects between Armv8.0 load, store exclusive instructions or Armv8.1 Large System Extension (LSE) atomic instructions based on CPU capability at runtime.
9+
10+
## Syntax
11+
12+
> **`/forceInterlockedFunctions`**[**`-`**]
13+
14+
## Remarks
15+
When possible, this flag avoids using Armv8.0 load and store exclusive instructions, as these instructions can result in livelocks.
16+
This flag forces the following interlocked intrinsics to be generated as out-of-line functions:
17+
18+
|Operation|8|16|32|64|128|Pointer|
19+
|-|-------|--------|--------|--------|-------|-------|
20+
|Add|None|None|Full|Full|None|None|
21+
|And|Full|Full|Full|Full|None|None|
22+
|CompareExchange|Full|Full|Full|Full|Full|Full|
23+
|Decrement|None|Full|Full|Full|None|None|
24+
|Exchange|Full|Full|Full|Full|None|Full|
25+
|ExchangeAdd|Full|Full|Full|Full|None|None|
26+
|Increment|None|Full|Full|Full|None|None|
27+
|Or|Full|Full|Full|Full|None|None|
28+
|Xor|Full|Full|Full|Full|None|None|
29+
|bittestandreset|None|None|Full|Full|None|None|
30+
|bittestandset|None|None|Full|Full|None|None|
31+
32+
Key:
33+
34+
- **Full**: supports plain, `_acq`, `_rel`, and `_nf` forms.
35+
36+
- **None**: Not supported
37+
38+
For more information about interlocked intrinsics, see the "Interlocked intrinsics" section in [Arm64 Intrinsics](../../intrinsics/arm64-intrinsics.md).
39+
40+
### To set the `/forceInterlockedFunctions` compiler option in Visual Studio
41+
42+
1. Open the **Property Pages** dialog box for the project. For more information, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
43+
44+
1. Select the **Configuration Properties** > **C/C++** > **Command Line** property page.
45+
46+
1. In the **Additional options** box, add *`/forceInterlockedFunctions`* to enable. Choose **OK** to save your changes.
47+
48+
### To set this compiler option programmatically
49+
50+
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
51+
52+
## See also
53+
[Arm64 Intrinsics](../../intrinsics/arm64-intrinsics.md)\
54+
[MSVC compiler options](compiler-options.md)\
55+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)

docs/build/reference/u-u-undefine-symbols.md

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
---
22
title: "/U, /u (Undefine symbols)"
33
description: "Use the Microsoft C/C++ compiler /U and /u options to undefine preprocessor symbols."
4-
ms.date: 09/03/2020
4+
ms.date: 04/14/2025
55
f1_keywords: ["VC.Project.VCCLCompilerTool.UndefinePreprocessorDefinitions", "VC.Project.VCCLWCECompilerTool.UndefinePreprocessorDefinitions", "VC.Project.VCCLCompilerTool.UndefineAllPreprocessorDefinitions", "/u", "VC.Project.VCCLWCECompilerTool.UndefineAllPreprocessorDefinitions"]
66
helpviewer_keywords: ["-U compiler option [C++]", "Undefine Symbols compiler option", "/U compiler option [C++]", "U compiler option [C++]"]
7-
ms.assetid: 7bc0474f-6d1f-419b-807d-0d8816763b2a
87
---
9-
# /U, /u (Undefine symbols)
8+
# `/U`, `/u` (Undefine symbols)
109

1110
The **`/U`** compiler option undefines the specified preprocessor symbol. The **`/u`** compiler option undefines the Microsoft-specific symbols that the compiler defines.
1211

@@ -17,7 +16,7 @@ The **`/U`** compiler option undefines the specified preprocessor symbol. The **
1716
1817
## Arguments
1918

20-
*symbol*<br/>
19+
*`symbol`*\
2120
The preprocessor symbol to undefine.
2221

2322
## Remarks
@@ -44,9 +43,7 @@ For a complete list of Microsoft-specific predefined macros, see [Predefined mac
4443
### To set this compiler option in the Visual Studio development environment
4544

4645
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](../working-with-project-properties.md).
47-
48-
1. Select the **Configuration Properties** > **C/C++** > **Advanced** property page.
49-
46+
1. Select the **Configuration Properties** > **C/C++** > **Preprocessor** property page.
5047
1. Modify the **Undefine Preprocessor Definitions** or **Undefine All Preprocessor Definitions** properties.
5148

5249
### To set this compiler option programmatically
@@ -55,9 +52,9 @@ For a complete list of Microsoft-specific predefined macros, see [Predefined mac
5552

5653
## See also
5754

58-
[MSVC compiler options](compiler-options.md)<br/>
59-
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)<br/>
60-
[**`/J`** (Default char type is unsigned)](j-default-char-type-is-unsigned.md)<br/>
61-
[**`/GR`** (Enable run-time type information)](gr-enable-run-time-type-information.md)<br/>
62-
[**`/EH`** (Exception handling model)](eh-exception-handling-model.md)<br/>
55+
[MSVC compiler options](compiler-options.md)\
56+
[MSVC compiler command-line syntax](compiler-command-line-syntax.md)\
57+
[**`/J`** (Default char type is unsigned)](j-default-char-type-is-unsigned.md)\
58+
[**`/GR`** (Enable run-time type information)](gr-enable-run-time-type-information.md)\
59+
[**`/EH`** (Exception handling model)](eh-exception-handling-model.md)\
6360
[**`/MD`**, **`/MT`**, **`/LD`** (Use run-time library)](md-mt-ld-use-run-time-library.md)

docs/build/toc.yml

+3
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@ items:
562562
href: ../build/reference/fc-full-path-of-source-code-file-in-diagnostics.md
563563
- name: /feature (Enable architecture features)
564564
href: ../build/reference/feature-arm64.md
565+
- name: /forceInterlockedFunctions (Generate and link with out-of-line atomic
566+
functions)
567+
href: ./reference/force-interlocked-functions.md
565568
- name: /fp (Specify floating-point behavior)
566569
href: ../build/reference/fp-specify-floating-point-behavior.md
567570
- name: /fpcvt (Floating-point to unsigned integer conversion behavior)

docs/code-quality/c26401.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public:
6363
ref_count_--;
6464
if (ref_count_ == 0)
6565
{
66-
[[gsl::suppress(i.11)]]
66+
[[gsl::suppress("i.11")]]
6767
delete this;
6868
}
6969
}

docs/code-quality/c26409.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public:
4949
ref_count_--;
5050
if (ref_count_ == 0)
5151
{
52-
[[gsl::suppress(i.11)]]
52+
[[gsl::suppress("i.11")]]
5353
delete this;
5454
}
5555
}

docs/code-quality/using-the-cpp-core-guidelines-checkers.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ int main()
7474
int arr[10]; // warning C26494
7575
int* p = arr; // warning C26485
7676

77-
[[gsl::suppress(bounds.1)]] // This attribute suppresses Bounds rule #1
77+
[[gsl::suppress("bounds.1", justification : "This attribute suppresses Bounds rules #1")]]
7878
{
7979
int* q = p + 1; // warning C26481 (suppressed)
8080
p = q++; // warning C26481 (suppressed)
@@ -104,7 +104,7 @@ c:\users\username\documents\visual studio 2015\projects\corecheckexample\coreche
104104
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
105105
```
106106

107-
The C++ Core Guidelines are there to help you write better and safer code. However, you might find an instance where a rule or a profile shouldn't be applied. It's easy to suppress it directly in the code. You can use the `[[gsl::suppress]]` attribute to keep C++ Core Check from detecting and reporting any violation of a rule in the following code block. You can mark individual statements to suppress specific rules. You can even suppress the entire bounds profile by writing `[[gsl::suppress(bounds)]]` without including a specific rule number.
107+
The C++ Core Guidelines are there to help you write better and safer code. However, you might find an instance where a rule or a profile shouldn't be applied. It's easy to suppress it directly in the code. You can use the `[[gsl::suppress]]` attribute to keep C++ Core Check from detecting and reporting any violation of a rule in the following code block. You can mark individual statements to suppress specific rules. You can even suppress the entire bounds profile by writing `[[gsl::suppress("bounds")]]` without including a specific rule number.
108108

109109
## Supported rule sets
110110

@@ -197,10 +197,10 @@ The Microsoft C++ compiler has limited support for the `[[gsl::suppress]]` attri
197197

198198
```cpp
199199
// Suppress only warnings from the 'r.11' rule in expression.
200-
[[gsl::suppress(r.11)]] new int;
200+
[[gsl::suppress("r.11")]] new int;
201201

202202
// Suppress all warnings from the 'r' rule group (resource management) in block.
203-
[[gsl::suppress(r)]]
203+
[[gsl::suppress("r")]]
204204
{
205205
new int;
206206
}
@@ -209,7 +209,7 @@ The Microsoft C++ compiler has limited support for the `[[gsl::suppress]]` attri
209209
// For declarations, you might need to use the surrounding block.
210210
// Macros are not expanded inside of attributes.
211211
// Use plain numbers instead of macros from the warnings.h.
212-
[[gsl::suppress(26400)]]
212+
[[gsl::suppress("26400")]]
213213
{
214214
int *p = new int;
215215
}

docs/cpp/attributes.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,18 @@ The `[[noreturn]]` attribute specifies that a function never returns; in other w
7777

7878
## Microsoft-specific attributes
7979

80-
### `[[gsl::suppress(rules)]]`
80+
### `[[gsl::suppress(<tag> [, justification: <narrow-string-literal>])]]`
8181

82-
The Microsoft-specific `[[gsl::suppress(rules)]]` attribute is used to suppress warnings from checkers that enforce [Guidelines Support Library (GSL)](https://github.com/Microsoft/GSL) rules in code. For example, consider this code snippet:
82+
`<tag>` is a string that specifies the name of the rule to suppress. The optional `justification` field allows you to explain why a warning is being disabled or suppressed. This value will appear in the SARIF output when the `/analyze:log:includesuppressed` option is specified. Its value is a UTF-8 encoded narrow string literal. The `[[gsl::suppress]]` attribute is available in Visual Studio 2022 version 17.14 and later versions.
83+
84+
The Microsoft-specific `[[gsl::suppress]]` attribute is used to suppress warnings from checkers that enforce [Guidelines Support Library (GSL)](https://github.com/Microsoft/GSL) rules in code. For example, consider this code snippet:
8385

8486
```cpp
8587
int main()
8688
{
8789
int arr[10]; // GSL warning C26494 will be fired
8890
int* p = arr; // GSL warning C26485 will be fired
89-
[[gsl::suppress(bounds.1)]] // This attribute suppresses Bounds rule #1
91+
[[gsl::suppress("bounds.1", justification: "This attribute suppresses Bounds rule #1")]]
9092
{
9193
int* q = p + 1; // GSL warning C26481 suppressed
9294
p = q--; // GSL warning C26481 suppressed
@@ -102,7 +104,7 @@ The example raises these warnings:
102104

103105
- [C26481](../code-quality/c26481.md) (Bounds Rule 1: Don't use pointer arithmetic. Use span instead.)
104106

105-
The first two warnings fire when you compile this code with the CppCoreCheck code analysis tool installed and activated. But the third warning doesn't fire because of the attribute. You can suppress the entire bounds profile by writing `[[gsl::suppress(bounds)]]` without including a specific rule number. The C++ Core Guidelines are designed to help you write better and safer code. The suppress attribute makes it easy to turn off the warnings when they aren't wanted.
107+
The first two warnings fire when you compile this code with the CppCoreCheck code analysis tool installed and activated. But the third warning doesn't fire because of the attribute. You can suppress the entire bounds profile by writing `[[gsl::suppress("bounds")]]` without including a specific rule number. The C++ Core Guidelines are designed to help you write better and safer code. The suppress attribute makes it easy to turn off the warnings when they aren't wanted.
106108

107109
### `[[msvc::flatten]]`
108110

docs/preprocessor/warning.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Enables selective modification of the behavior of compiler warning messages.
1313
## Syntax
1414

1515
> **`#pragma warning(`**\
16-
> &emsp;*`warning-specifier`* **`:`** *`warning-number-list`*\
16+
> &emsp;*`warning-specifier`* **`:`** *`warning-number-list`* [ **`,`** **`justification`** **`:`** *`string-literal`*]\
1717
> &emsp;[**`;`** *`warning-specifier`* **`:`** *`warning-number-list`* ... ] **`)`**\
1818
> **`#pragma warning( push`** [ **`,`** *n* ] **`)`**\
1919
> **`#pragma warning( pop )`**
@@ -26,17 +26,26 @@ The following warning-specifier parameters are available.
2626
|--|--|
2727
| `1`, `2`, `3`, `4` | Apply the given level to the specified warnings. Also turns on a specified warning that is off by default. |
2828
| `default` | Reset warning behavior to its default value. Also turns on a specified warning that is off by default. The warning will be generated at its default, documented, level.<br /><br /> For more information, see [Compiler warnings that are off by default](../preprocessor/compiler-warnings-that-are-off-by-default.md). |
29-
| `disable` | Don't issue the specified warning messages. |
29+
| `disable` | Don't issue the specified warning messages. The optional **`justification`** property is allowed. |
3030
| `error` | Report the specified warnings as errors. |
3131
| `once` | Display the specified message(s) only one time. |
32-
| `suppress` | Pushes the current state of the pragma on the stack, disables the specified warning for the next line, and then pops the warning stack so that the pragma state is reset. |
32+
| `suppress` | Pushes the current state of the pragma on the stack, disables the specified warning for the next line, and then pops the warning stack so that the pragma state is reset. The optional **`justification`** property is allowed. |
3333

3434
The following code statement illustrates that a *`warning-number-list`* parameter can contain multiple warning numbers, and that multiple *`warning-specifier`* parameters can be specified in the same pragma directive.
3535

3636
```cpp
3737
#pragma warning( disable : 4507 34; once : 4385; error : 164 )
3838
```
3939

40+
However, when the **`justification`** field is present, only one warning number can be specified. The following code statement illustrates the use of the **`justification`** field.
41+
42+
```cpp
43+
#pragma warning( disable : 4507, justification : "This warning is disabled" )
44+
```
45+
46+
The **`justification`** fields allows you to explain why a warning is being disable or
47+
suppressed. The **`justification`** field is only supported for the **`disable`** and **`suppress`** *`warning-specifier`*. This value will appear in the SARIF output when the `/analyze:log:includesuppressed` option is specified. Its value is a UTF-8 encoded narrow string literal.
48+
4049
This directive is functionally equivalent to the following code:
4150

4251
```cpp

0 commit comments

Comments
 (0)