Preprocessor Directive #error In C
Contents |
message. You would use ‘#error’ inside of
#error C++
a conditional that detects a combination of #error c preprocessor parameters which you know the program does not properly support. For
#error Gcc
example, if you know that the program will not run properly on a VAX, you might write #ifdef __vax__ #error access #error "Won't work on VAXen. See comments at get_last_object." #endif If you have several configuration parameters that must be set up by the installation in a consistent way, you can use conditionals to detect an inconsistency and report #warning in c it with ‘#error’. For example, #if !defined(FOO) && defined(BAR) #error "BAR requires FOO." #endif The directive ‘#warning’ is like ‘#error’, but causes the preprocessor to issue a warning and continue preprocessing. The tokens following ‘#warning’ are used as the warning message. You might use ‘#warning’ in obsolete header files, with a message directing the user to the header file which should be used instead. Neither ‘#error’ nor ‘#warning’ macro-expands its argument. Internal whitespace sequences are each replaced with a single space. The line must consist of complete tokens. It is wisest to make the argument of these directives be a single string constant; this avoids problems with apostrophes and the like.
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft
Error Directive Must Use C++ For The Type Iostream
Student Partners ISV Startups TechRewards Events Community Magazine Forums #error in excel Blogs Channel 9 Documentation APIs and reference Dev centers Samples Retired content We’re sorry.
#error In Webi
The content you requested has been removed. You’ll be auto redirected in 1 second. C/C++ Preprocessor Reference Preprocessor Preprocessor Directives Preprocessor Directives https://gcc.gnu.org/onlinedocs/cpp/Diagnostics.html #error Directive #error Directive #error Directive #define Directive #error Directive #if, #elif, #else, and #endif Directives #ifdef and #ifndef Directives #import Directive #include Directive #line Directive Null Directive #undef Directive #using Directive TOC Collapse the table of content Expand the table of content This documentation is https://msdn.microsoft.com/en-us/library/c8tk0xsk.aspx archived and is not being maintained. This documentation is archived and is not being maintained. #error Directive (C/C++) Visual Studio 2015 Other Versions Visual Studio 2013 Visual Studio 2012 Visual Studio 2010 Visual Studio 2008 Visual Studio 2005 Visual Studio .NET 2003 The #error directive emits a user-specified error message at compile time and then terminates the compilation.Syntax Copy #errortoken-string RemarksThe error message that this directive emits includes the token-string parameter. The token-string parameter is not subject to macro expansion. This directive is most useful during preprocessing for notifying the developer of a program inconsistency or the violation of a constraint. The following example demonstrates error processing during preprocessing: Copy #if !defined(__cplusplus) #error C++ compiler required. #endif See AlsoPreprocessor Directives Show: Inherited Protected Print Export (0) Print Export (0) Share IN THIS ARTICLE Is this pa
and often underused preprocessor directive. Behaviour of this preprocessor directive is the same for both C and C++ compilers. Purpose The #error directive terminates compilation and outputs the text following the directive. http://www.complete-concrete-concise.com/programming/c/preprocessor-%E2%80%93-the-error-directive Format #error text All preprocessor directives begin with the # symbol. It must be the first character on the line or the first character on the line following optional white space. Some early compilers flagged an error if # was not the first character on the line. Spaces or tabs are permitted between the # and error, but not #error in escape characters or other symbols or macros. The preprocessor removes white space and concatenates the # and error together. If anything follows the #error directive (other than white space) then the program is malformed. The following are valid uses: #error some error message text # error some error text to display # /* comments are white space */ error some preprocessor directive #error error message to display The following are invalid uses: // #\ is not a valid preprocessor directive # \t error text to output // #" is not a valid preprocessor directive # "" text to output Use It is used to render a program malformed and output the text following the #error directive. The text may be quoted or unquoted (it doesn't matter). No macro expansion takes place. The language specifications do not say how the text following the #error directive is to be treated. The GCC compiler, replaces all white space characters between tokens with a single white space character. I have no reason to believe other compilers behave differently since white space is not considered significant in the C and C++ languages - it serves only to seperate tokens from one another. There are many times when it is useful to halt compilation: code is incomplete code requires particular library versions code uses compiler dependent features code has specific compiler requirements Incomplete Code When developing code, it is common to create stub functions. For the fi