Skip to content

Commit 4132e72

Browse files
committed
docs for justification in pragma warning
1 parent fede28a commit 4132e72

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

docs/preprocessor/warning.md

Lines changed: 12 additions & 3 deletions
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-
>  *`warning-specifier`* **`:`** *`warning-number-list`*\
16+
>  *`warning-specifier`* **`:`** *`warning-number-list`* [ **`,`** **`justification`** **`:`** *`string-literal`*]\
1717
>  [**`;`** *`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)