C Language #error Directive
Contents |
message. You would use ‘#error’ inside of
#error C
a conditional that detects a combination of #error in c example parameters which you know the program does not properly support. For
#error C++
example, if you know that the program will not run properly on a VAX, you might write #ifdef __vax__ #error c preprocessor #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 #error gcc 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 Student Partners ISV
#warning In C
Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation error directive must use c++ for the type iostream APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has
K&r Preferred Method
been removed. You’ll be auto redirected in 1 second. C/C++ Preprocessor Reference Preprocessor Preprocessor Directives Preprocessor Directives #error Directive #error Directive #error Directive #define Directive https://gcc.gnu.org/onlinedocs/cpp/Diagnostics.html #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 archived and is not being maintained. This documentation is archived and https://msdn.microsoft.com/en-us/library/c8tk0xsk.aspx 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 page helpful? Yes No Additional feedback? 1500 characters remaining Submit Skip this Thank you! We appreciate your feedback. Dev centers Windows Office Visual
MySQL MariaDB PostgreSQL SQLite MS Office Excel Access Word Web Development HTML CSS Color Picker Languages C Language More ASCII Table Linux UNIX Java Clipart Techie Humor Advertisement C Language Introduction Compiling and Linking File Naming Preprocessor Directives #include https://www.techonthenet.com/c_language/directives/error.php #define #undef #if #ifdef #ifndef #elif #else #endif #warning #error Comments Variables Integer Variables Float Variables First Program assert.h Functions ctype.h Functions locale.h Functions math.h Functions setjmp.h Functions signal.h Functions stdarg.h Functions stdio.h Functions stdlib.h Functions http://en.cppreference.com/w/cpp/preprocessor/error string.h Functions time.h Functions NEXT: Comments C Language: #error Directive This C tutorial explains how to use the #error preprocessor directive in the C language. Description In the C Programming Language, the #error directive causes #error c preprocessing to stop at the location where the directive is encountered. Information following the #error directive is output as a message prior to stopping preprocessing. Syntax The syntax for the #error directive in the C language is: #error message message Message to output prior to stopping preprocessing. Example Let's look at how to use #error directives in your C program. The following example shows the output of the #error directive: /* c language #error Example using #error directive by TechOnTheNet.com */ #include
Strings library Containers library Algorithms library Iterators library Numerics library Input/output library Localizations library Regular expressions library (C++11) Atomic operations library (C++11) Thread support library (C++11) Filesystem library (C++17) Technical Specifications [edit] C++ language General topics Preprocessor Comments Keywords Escape sequences Flow control Conditional execution statements if switch Iteration statements (loops) for range-for (C++11) while do-while Jump statements continue - break goto - return Functions Function declaration Lambda function declaration inline specifier Exception specifications (deprecated) noexcept specifier (C++11) Exceptions throw-expression try-catch block Namespaces Namespace declaration Namespace aliases Types Fundamental types Enumeration types Function types Compound types Union types Specifiers decltype (C++11) auto (C++11) alignas (C++11) const/volatile constexpr (C++11) Storage duration specifiers Initialization Default initialization Value initialization Zero initialization Copy initialization Direct initialization Aggregate initialization List initialization (C++11) Constant initialization Reference initialization Expressions Value categories Order of evaluation Operators Operator precedence Alternative representations Literals Boolean - Integer - Floating-point Character - String - nullptr (C++11) User-defined (C++11) Utilities Attributes (C++11) Types typedef declaration Type alias declaration (C++11) Casts Implicit conversions - Explicit conversions static_cast - dynamic_cast const_cast - reinterpret_cast Memory allocation new expression delete expression Classes Class declaration Initializer lists this pointer Access specifiers friend specifier Class-specific function properties Virtual function override specifier (C++11) final specifier (C++11) explicit (C++11) static Special member functions Default constructor Copy constructor Move constructor (C++11) Copy assignment Move assignment (C++11) Destructor Te