Error C Preprocessor
Contents |
#error inside of c preprocessor error examples a conditional that detects a combination of definition of preprocessor in c parameters which you know the program does not properly support. For
Preprocessor Command
example, if you know that the program will not run properly on a VAX, you might write #ifdef __vax__
Preprocessor In Cpp
#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 c preprocessor characters it with #error. For example, #if !defined(UNALIGNED_INT_ASM_OP) && defined(DWARF2_DEBUGGING_INFO) #error "DWARF2_DEBUGGING_INFO requires UNALIGNED_INT_ASM_OP." #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.
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss
C Compiler Directives
the workings and policies of this site About Us Learn more c preprocessing about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow error c windows system32 rundll32 exe Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each http://gcc.gnu.org/onlinedocs/gcc-3.3.5/cpp/Diagnostics.html other. Join them; it only takes a minute: Sign up Portability of #warning preprocessor directive up vote 38 down vote favorite 2 I know that the #warning directive is not standard C/C++, but several compilers support it, including gcc/g++. But for those that don't support it, will they silently ignore it or will it result in a compile http://stackoverflow.com/questions/171435/portability-of-warning-preprocessor-directive failure? In other words, can I safely use it in my project without breaking the build for compilers that don't support it? c++ compiler-construction warnings c-preprocessor portability share|improve this question edited Jun 3 at 20:00 Brian Tompsett - 汤莱恩 3,093122775 asked Oct 5 '08 at 3:40 jonner 3,05051927 add a comment| 5 Answers 5 active oldest votes up vote 19 down vote accepted It is likely that if a compiler doesn't support #warning, then it will issue an error. Unlike #pragma, there is no recommendation that the preprocessor ignore directives it doesn't understand. Having said that, I've used compilers on various different (reasonably common) platforms and they have all supported #warning. share|improve this answer answered Oct 5 '08 at 3:53 Greg Hewgill 510k1088801044 add a comment| up vote 60 down vote It should be noted that MSVC uses the syntax: #pragma message ( "your warning text here" ) The usual #warning syntax generates a fatal error C1021: invalid preprocessor command 'warning' so it is not portable to those compilers. share|improve this answe
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners https://msdn.microsoft.com/en-us/library/c8tk0xsk.aspx ISV Startups TechRewards Events Community Magazine Forums Blogs Channel http://www.barrgroup.com/embedded-systems/how-to/c-preprocessor-error-directive 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. C/C++ Preprocessor Reference Preprocessor Preprocessor Directives Preprocessor Directives #error Directive #error Directive c preprocessor #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 archived and is not being maintained. preprocessor in c 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 page helpful? Yes No Additional feedback? 1500 characters remaining Submit Skip this
Witness ExpertiseProduct Liability Automotive Electronics Medical Device Design Computer Security Process & Architecture Safety & Reliability all... How-ToArticles Books Coding Standard Glossary Webinars Skills Tests Surveys BlogsNews Barr Code Coding Standards Device Security Expert Witness Software Safety Registration for Fall Training Courses Now Open. See our complete training calendar. Glossary Find definitions for technical terms in our Embedded Systems Glossary. A B C D EF G H I JK L M N OP Q R S TU V W X YZ Symbols Test Your Skills How good are your embedded programming skills? Test yourself in the Embedded C Quiz or the Embedded C++ Quiz. Newsletter Signup Want to receive free how-to articles and industry news as well as announcements of free webinars and other training courses by e-mail? Signup Today! How to Use the C Preprocessor's #error Directive Wed, 1999-09-01 00:00 - Nigel Jones by Nigel Jones One of the least used but potentially most useful features of the C preprocessor is the ANSI-specified #error directive. Here's a look at a couple of clever uses for #error that have proven invaluable in embedded software development. The syntax of #error is very straightforward: #error