Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 1.16 KB

hash-warning-directive-c-cpp.md

File metadata and controls

29 lines (21 loc) · 1.16 KB
description title ms.date f1_keywords helpviewer_keywords
Learn more about: #warning directive (C/C++)
#warning directive (C/C++)
11/08/2023
#warning
#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:

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

See also

Preprocessor directives
#error directive