Skip to content
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

Create warning directive page #4804

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 1 deletion docs/preprocessor/hash-error-directive-c-cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ The error message that this directive emits includes the *token-string* paramete

## See also

[Preprocessor directives](../preprocessor/preprocessor-directives.md)
[Preprocessor directives](../preprocessor/preprocessor-directives.md)\
[#warning directive](../preprocessor/hash-warning-directive-c-cpp.md)
29 changes: 29 additions & 0 deletions docs/preprocessor/hash-warning-directive-c-cpp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
description: "Learn more about: #warning directive (C/C++)"
title: "#warning directive (C/C++)"
ms.date: "11/08/2023"
f1_keywords: ["#warning"]
helpviewer_keywords: ["#warning directive", "preprocessor, directives", "warning directive (#warning directive)"]
---
# #warning directive (C/C++)

The **#warning** directive emits a user-specified warning message at compile time, and does not stop the compilation. This directive is a standard feature since C23 and C++23.

## Syntax

> **#warning** *token-string*

## Remarks

The warning message that this directive emits includes the *token-string* parameter. The *token-string* parameter is not subject to macro expansion and can be optionally enclosed in quotes. This directive is used to inform the developer of a non-fatal issue that may have occured, or to disseminate important information. The following example shows how the **#warning** directive is used:

```cpp
#if defined(_LEGACY_FEATURE_FLAG)
#warning "_LEGACY_FEATURE is deprecated and should not be used."
#endif
```

## See also

[Preprocessor directives](../preprocessor/preprocessor-directives.md)\
[#error directive](../preprocessor/hash-error-directive-c-cpp.md)
3 changes: 2 additions & 1 deletion docs/preprocessor/preprocessor-directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ The preprocessor recognizes the following directives:
:::column span="":::
[`#import`](../preprocessor/hash-import-directive-cpp.md)\
[`#include`](../preprocessor/hash-include-directive-c-cpp.md)\
[`#line`](../preprocessor/hash-line-directive-c-cpp.md)
[`#line`](../preprocessor/hash-line-directive-c-cpp.md)\
[`#warning`](../preprocessor/hash-warning-directive-c-cpp.md)
:::column-end:::
:::column span="":::
[`#pragma`](../preprocessor/pragma-directives-and-the-pragma-keyword.md)\
Expand Down
2 changes: 2 additions & 0 deletions docs/preprocessor/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ items:
href: ../preprocessor/hash-undef-directive-c-cpp.md
- name: "#using directive (C++/CLI)"
href: ../preprocessor/hash-using-directive-cpp.md
- name: "#warning directive (C/C++)"
href: ../preprocessor/hash-warning-directive-c-cpp.md
- name: Preprocessor operators
expanded: false
items:
Expand Down