From d06be5ab741f5d14701632d8207645e9c9c43722 Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Wed, 8 Nov 2023 18:19:18 +0800 Subject: [PATCH 1/3] Create warning directive page --- .../hash-error-directive-c-cpp.md | 3 +- .../hash-warning-directive-c-cpp.md | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 docs/preprocessor/hash-warning-directive-c-cpp.md diff --git a/docs/preprocessor/hash-error-directive-c-cpp.md b/docs/preprocessor/hash-error-directive-c-cpp.md index 2a5ec7bfe9..17d7504cdf 100644 --- a/docs/preprocessor/hash-error-directive-c-cpp.md +++ b/docs/preprocessor/hash-error-directive-c-cpp.md @@ -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) diff --git a/docs/preprocessor/hash-warning-directive-c-cpp.md b/docs/preprocessor/hash-warning-directive-c-cpp.md new file mode 100644 index 0000000000..df65b63c15 --- /dev/null +++ b/docs/preprocessor/hash-warning-directive-c-cpp.md @@ -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) From 6f18afeaf6c5bde1f41d25153620c011b6b418c9 Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Wed, 8 Nov 2023 18:23:52 +0800 Subject: [PATCH 2/3] Add `#warning` to `preprocessor-directives` page --- docs/preprocessor/preprocessor-directives.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/preprocessor/preprocessor-directives.md b/docs/preprocessor/preprocessor-directives.md index 38d13833a8..a332eff81b 100644 --- a/docs/preprocessor/preprocessor-directives.md +++ b/docs/preprocessor/preprocessor-directives.md @@ -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)\ From c523295501c6c9c064e970365e107c0cf79159d2 Mon Sep 17 00:00:00 2001 From: Rageking8 <106309953+Rageking8@users.noreply.github.com> Date: Wed, 8 Nov 2023 18:27:14 +0800 Subject: [PATCH 3/3] Add `#warning` page to `toc.yml` --- docs/preprocessor/toc.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/preprocessor/toc.yml b/docs/preprocessor/toc.yml index a2121985ad..42bf5bd75e 100644 --- a/docs/preprocessor/toc.yml +++ b/docs/preprocessor/toc.yml @@ -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: