Home > c preprocessor > gcc preprocessor error directive

Gcc Preprocessor Error Directive

Contents

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies

#error C Preprocessor

of this site About Us Learn more about Stack Overflow the company #error gcc Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges

C Preprocessor Message

Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: invalid preprocessor command 'warning' Sign up How do I generate an error or warning in the C preprocessor? up vote 19 down vote favorite 1 I have a program that must be compiled only in DEBUG mode. (testing purpose) How can I have the preprocessor prevent compilation in RELEASE mode? c-preprocessor share|improve this question edited Jun 25 at 23:11 phs 7,05722761 asked Feb 8 '10 at #error c++ 12:29 Eonil 31.1k43203377 add a comment| 7 Answers 7 active oldest votes up vote 34 down vote accepted Place anywhere: #ifndef DEBUG #error Only Debug builds are supported #endif share|improve this answer answered Feb 8 '10 at 12:33 Hans Passant 655k819611605 add a comment| up vote 11 down vote C provide a #error statement, and most compilers add a #warning statement. The gcc documentation recommends to quote the message. share|improve this answer edited Nov 17 '15 at 17:28 answered Feb 8 '10 at 12:37 philant 22.9k94890 1 @Antonio Right, there is no [more] recommendation there. I replaced the link with one to gcc doc. –philant Nov 17 '15 at 17:29 add a comment| up vote 4 down vote You can use a error directive for that. The following code will throw an error at compile time if DEBUG is not defined: #ifndef DEBUG #error This is an error message #endif share|improve this answer edited Feb 8 '10 at 23:32 answered Feb 8 '10 at 12:34 Laurent Etiemble 21k44075 Sorry, I mix pragma and error while typing. Corrected in answer. –Laurent Etie

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more

Gcc #message

about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users #error in c example Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping

#warning In C

each 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 http://stackoverflow.com/questions/2221517/how-do-i-generate-an-error-or-warning-in-the-c-preprocessor gcc/g++. But for those that don't support it, will they silently ignore it or will it result in a compile 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,091132775 asked Oct 5 '08 at 3:40 jonner 3,05551927 add a comment| 5 Answers 5 active oldest votes http://stackoverflow.com/questions/171435/portability-of-warning-preprocessor-directive 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 511k1088801044 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 answer answered Nov 11 '08 at 0:30 nolandda 1,09721015 20 This is one of the rare cases, when MS does things in the right way. –doc Aug 5 '10 at 14:05 Is MSVC syntax portable? I mean, would it properly generate a warning with other compilers? –aka.nice Jun 11 '13 at 13:34 Just ran a quick check using gcc-4.7.2. [$ gcc -c -Werror file.c] yields [file.c:10:9: note: #pragma message: Foo bar baz] So it produces a "note" that is not treated as a warning (i.e. It doesn't fail the build with -Werror enabled). But it appears parse correctly (as all #pragmas should be) so it is portable in that sense

tokens Description #error emits tokens to standard error, and increments the assembler error counter, hereby preventing the program from being successfully assembled. #error is specified in the ANSI C standard. #warning emits tokens to standard error, and increments the assembler warning http://www.atmel.com/webdoc/avrassembler/avrassembler.wb_preprocessor.error.html counter. #warning is not specified in the ANSI C standard, but is commonly implemented in preprocessors such as the GNU C preprocessor. #message emits tokens to standard output, and does not affect assembler error or warning counters. http://tigcc.ticalc.org/doc/cpp.html #message is not specified in the ANSI C standard.For all directives, the output will include file name and line number, like normal error and warning messages.tokens is a sequence of preprocessor tokens. Preprocessor macros are expanded c preprocessor except if appearing inside quoted strings (").Example #error "Unsupported part:" __PART_NAME__ PrevUpNextHomeContentsSearchDocumentation HomeAVR AssemblerPrefaceAVR Assembler Known IssuesAVR Assembler Command Line OptionsAssembler sourceAVR Assembler SyntaxAssembler directivesAVR Assembler PreprocessorIntroductionPreprocessor directives#define#undef#ifdef#ifndef#if and #elif#else#endif#error, #warning and #message#include#pragma, general purpose#pragma , AVR part related# (empty directive)OperatorsStringification (#)Concatenation (##)Pre-defined macrosExpressionsInstruction mnemonicsArithmetic and logic instructionsBranch InstructionsData Transfer InstructionsBit and Bit-test InstructionsI/O RegistersInstruction Set Nomenclature:Instructions ADC - Add with Carry ADD - Add without Carry ADIW - Add Immediate to Word AND gcc preprocessor error - Logical AND ANDI - Logical AND with Immediateand ASR - Arithmetic Shift Right BCLR - Bit Clear in SREG BLD - Bit Load from the T Flag in SREG to a Bit in Register. BRBC - Branch if Bit in SREG is Cleared BRBS - Branch if Bit in SREG is Set BRCC - Branch if Carry Cleared BRCS - Branch if Carry Set BREAK - Break BREQ - Branch if Equal BRGE - Branch if Greater or Equal Signed) BRHC - Branch if Half Carry Flag is Cleared BRHS - Branch if Half Carry Flag is Set BRID - Branch if Global Interrupt is Disabled BRIE - Branch if Global Interrupt is Enabled BRLO - Branch if Lower (Unsigned) BRLT - Branch if Less Than (Signed) BRMI - Branch if Minus BRNE - Branch if Not Equal BRPL - Branch if Plus BRSH - Branch if Same or Higher (Unsigned) BRTC - if the T Flag is Cleared BRTS - Branch if the T Flag is Set BRVC - Branch if Overflow Cleared BRVS - Branch if Overflow Set BSET - Bit Set in SREG BST - Bit Store from Bit in Register to T Flag in SREG CALL - Long Call to a Subroutine CBI - Clear Bit in I/O Register CBR - Clear Bi

the C compiler to transform your program before actual compilation. It is called a macro processor because it allows you to define macros, which are brief abbreviations for longer constructs. Preprocessor Overview Header Files Macros Conditionals Pragmas Other Directives User-defined Diagnostics Line Control Preprocessor Output C Preprocessor Command-Line Options Traditional Mode Implementation Details History GNU General Public License GNU Free Documentation License Funding Free Software Original author: Free Software Foundation, Inc. Authors of the modifications: Zeljko Juric, Sebastian Reichelt, and Kevin Kofler Published by the TIGCC Team. See the History section for details and copyright information. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation. A copy of the license is included in the section entitled "GNU Free Documentation License". This manual contains no Invariant Sections. The Front-Cover Texts are (a) (see below), and the Back-Cover Texts are (b) (see below). (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. Preprocessor Overview The C preprocessor, often known as cpp, is a macro processor that is used automatically by the C compiler to transform your program before compilation. It is called a macro processor because it allows you to define macros, which are brief abbreviations for longer constructs. The C preprocessor is intended to be used only with C, C++, and Objective-C source code. In the past, it has been abused as a general text processor. It will choke on input which does not obey C's lexical rules. For example, apostrophes will be interpreted as the beginning of character constants, and cause errors. Also, you cannot rely on it preserving characteristics of the input which are not significant to C-family languages. If a Makefile is preprocessed, all the hard tabs will be removed, and the Makefile will not work. Having said that, you can often get away with using cpp on things which are not C. Other Algol-ish programming languages are often safe (Pascal, Ada, etc.) So is assembly, with caution. '-traditional-cpp' mode preserves

 

Related content

ansi c preprocessor #error

Ansi C Preprocessor error table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor Stringify a li li a href C Preprocessor Stringize a li li a href C Preprocessor Tricks a li ul td tr tbody table p message relatedl You would use lsquo error rsquo inside of configure error c preprocessor a conditional that detects a combination of configure error c preprocessor lib cpp fails sanity check centos parameters which you know the program does not properly support For c preprocessor if example if you know that the program will not

#error #warning c preprocessor

error warning C Preprocessor table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor Error Macro a li li a href C Preprocessor Tutorial a li li a href C Preprocessor Concatenate a li ul td tr tbody table p message relatedl You would use lsquo error rsquo inside of c preprocessor error directive a conditional that detects a combination of p h id C Preprocessor Error Macro p parameters which you know the program does not properly support For c preprocessor define example if you know that the program will not run

cpp preprocessor error

Cpp Preprocessor Error table id toc tbody tr td div id toctitle Contents div ul li a href Cpp Preprocessor Directives a li li a href C Preprocessor If a li li a href C Preprocessor Stringify a li li a href C Preprocessor Definitions a li ul td tr tbody table p message relatedl You would use lsquo error rsquo inside of p h id Cpp Preprocessor Directives p a conditional that detects a combination of c preprocessor lib cpp fails sanity check parameters which you know the program does not properly support For gcc preprocessor error example if

configure error c preprocessor lib cpp

Configure Error C Preprocessor Lib Cpp table id toc tbody tr td div id toctitle Contents div ul li a href Checking How To Run The C Preprocessor lib cpp a li li a href Checking How To Run The C Preprocessor lib cpp a li li a href C Preprocessor Fails Sanity Check Ubuntu a li ul td tr tbody table p configure error lib cpp fails sanity p h id Checking How To Run The C Preprocessor lib cpp p check SOLVED From nospam at nospam dot net lib cpp fails sanity check ubuntu To gcc-help at gcc

c preprocessor error pragma

C Preprocessor Error Pragma table id toc tbody tr td div id toctitle Contents div ul li a href Ifdef Preprocessor a li li a href Pragma In C a li li a href pragma In Embedded C a li ul td tr tbody table p Three forms of this directive commonly known as pragmas are specified by the C standard A C compiler is free to attach any meaning it likes to other pragmas relatedl GCC has historically preferred to use extensions to the syntax c preprocessor error directive of the language such as attribute for this purpose However

c preprocessor error

C Preprocessor Error table id toc tbody tr td div id toctitle Contents div ul li a href Error C Windows System Rundll Exe a li li a href C Preprocessor If a li li a href C Preprocessor Define a li ul td tr tbody table p message relatedl You would use lsquo error rsquo inside of c preprocessor error directive a conditional that detects a combination of c preprocessor error macro parameters which you know the program does not properly support For ifdef preprocessor example if you know that the program will not run properly on a VAX

c preprocessor macros #error

C Preprocessor Macros error table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor Macros Multiple Lines a li li a href C Preprocessor Macro Variable Arguments a li li a href C Preprocessor Macro Concatenation a li li a href C Preprocessor Macro If a li ul td tr tbody table p message relatedl You would use lsquo error rsquo inside of p h id C Preprocessor Macros Multiple Lines p a conditional that detects a combination of c preprocessor macro arguments parameters which you know the program does not properly support

c preprocessor #error directive

C Preprocessor error Directive table id toc tbody tr td div id toctitle Contents div ul li a href Visual Studio Preprocessor Directives a li li a href Pre Processor Directive In C a li li a href error Gcc a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta relatedl Discuss the workings and policies of this site About c preprocessor directives examples Us Learn more about Stack Overflow the company Business Learn more about hiring p h id Visual Studio Preprocessor

c preprocessor throw error

C Preprocessor Throw Error table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor Tutorial a li li a href C Preprocessor Ifdef a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us relatedl Learn more about Stack Overflow the company Business Learn more about hiring c preprocessor error directive developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask c

c preprocessor #warning #error

C Preprocessor warning error table id toc tbody tr td div id toctitle Contents div ul li a href Preprocessor Warning Message a li li a href C Preprocessor Define a li li a href C Preprocessor Tutorial a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions relatedl you might have Meta Discuss the workings and policies c preprocessor error directive of this site About Us Learn more about Stack Overflow the company c preprocessor error macro Business Learn more about hiring developers or posting ads

c preprocessor error and warning

C Preprocessor Error And Warning table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor Error Macro a li li a href C Preprocessor Define a li li a href C Preprocessor If a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn relatedl more about Stack Overflow the company Business Learn more about hiring c preprocessor error directive developers or posting ads with us

c preprocessor error message

C Preprocessor Error Message table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor Error Macro a li li a href C Preprocessor Tutorial a li li a href C Preprocessor Concatenate a li ul td tr tbody table p p p resources Windows Server resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events relatedl Community Magazine Forums Blogs Channel Documentation APIs and c preprocessor ifdef reference Dev centers Retired content Samples We re sorry The content you requested c preprocessor operator has been removed

c preprocessor error warning

C Preprocessor Error Warning table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor Error Directive a li li a href C Preprocessor If a li li a href C Preprocessor Tutorial a li li a href C Preprocessor Operator a li ul td tr tbody table p p p tokens Description error emits tokens to standard error relatedl and increments the assembler error counter hereby c preprocessor ifdef preventing the program from being successfully assembled error is p h id C Preprocessor Operator p specified in the ANSI C standard warning emits

c language preprocessor #error

C Language Preprocessor error table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor Error Directive a li li a href C Compiler Preprocessor a li li a href C Sharp Preprocessor a li li a href Perl Preprocessor a li ul td tr tbody table p error inside of p h id C Preprocessor Error Directive p a conditional that detects a combination of c preprocessor error macro parameters which you know the program does not properly support For c programming preprocessor example if you know that the program will not run

c preprocessor error macro

C Preprocessor Error Macro table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor Macro Variable Arguments a li li a href C Preprocessor Macro Concatenation a li li a href C Preprocessor Macro If a li ul td tr tbody table p message relatedl You would use lsquo error rsquo inside of c preprocessor macro arguments a conditional that detects a combination of c preprocessor macro tricks parameters which you know the program does not properly support For p h id C Preprocessor Macro Variable Arguments p example if you know that

configure error c preprocessor lib cpp fails sanity check

Configure Error C Preprocessor Lib Cpp Fails Sanity Check table id toc tbody tr td div id toctitle Contents div ul li a href Configure Error C Preprocessor Lib Cpp Fails Sanity Check Centos a li li a href Configure Error C Preprocessor Lib Cpp Fails Sanity Check Os X a li ul td tr tbody table p communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview relatedl of the site Help Center Detailed answers gentoo configure error c preprocessor lib cpp fails sanity check to any

configure error c preprocessor

Configure Error C Preprocessor table id toc tbody tr td div id toctitle Contents div ul li a href Configure Error C Preprocessor lib cpp Fails Sanity Check a li li a href C Preprocessor Error Directive a li li a href C Preprocessor Error Macro a li li a href C Preprocessor If a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions relatedl you might have Meta Discuss the workings and policies p h id Configure Error C Preprocessor lib cpp Fails Sanity Check p

configure error c preprocessor /lib/cpp fails

Configure Error C Preprocessor lib cpp Fails table id toc tbody tr td div id toctitle Contents div ul li a href Checking How To Run The C Preprocessor lib cpp a li li a href Uuid Support Not Found a li li a href C Preprocessor Fails Sanity Check Ubuntu a li ul td tr tbody table p communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a relatedl quick overview of the site Help Center configure error c preprocessor lib cpp fails sanity check centos Detailed answers to

error c preprocessor /lib/cpp

Error C Preprocessor lib cpp table id toc tbody tr td div id toctitle Contents div ul li a href Error C Preprocessor Lib Cpp Fails Sanity Check a li li a href Lib Cpp Fails Sanity Check Ubuntu a li li a href C Preprocessor Fails Sanity Check Centos a li li a href C Preprocessor Fails Sanity Check Ubuntu a li ul td tr tbody table p communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview relatedl of the site Help Center Detailed answers p

error c preprocessor

Error C Preprocessor table id toc tbody tr td div id toctitle Contents div ul li a href Preprocessor Command a li li a href Preprocessor In Cpp a li li a href C Compiler Directives a li ul td tr tbody table p 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 p h id Preprocessor Command p example if you know that the program will not run properly on a VAX you might write ifdef vax p

error preprocessor c

Error Preprocessor C table id toc tbody tr td div id toctitle Contents div ul li a href Error C Windows System Rundll Exe a li li a href C Preprocessor Warning a li li a href C Preprocessor Error Macro a li li a href C Preprocessor Concatenate a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings relatedl and policies of this site About Us Learn more about c preprocessor error directive Stack Overflow the company Business Learn

error preprocessor in c

Error Preprocessor In C table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor If a li li a href C Preprocessor Error Macro a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this relatedl site About Us Learn more about Stack Overflow the company c preprocessor error directive Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs error c windows system rundll

gcc preprocessor error

Gcc Preprocessor Error table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor Message a li li a href error C a li li a href warning C a li ul td tr tbody table p message relatedl You would use lsquo error rsquo inside of error c preprocessor a conditional that detects a combination of p h id C Preprocessor Message p parameters which you know the program does not properly support For gcc pragma message example if you know that the program will not run properly on a VAX you might

gcc preprocessor #error #warning

Gcc Preprocessor error warning table id toc tbody tr td div id toctitle Contents div ul li a href C Preprocessor Message a li li a href Invalid Preprocessor Command warning a li ul td tr tbody table p message relatedl You would use lsquo error rsquo inside of gcc warning a conditional that detects a combination of gcc pragma message parameters which you know the program does not properly support For warning c example if you know that the program will not run properly on a VAX you might write ifdef vax error in c error Won't work on

preprocessor #error variable

Preprocessor error Variable table id toc tbody tr td div id toctitle Contents div ul li a href Gcc Pragma Message a li li a href Gcc Preprocessor Print Macro Value a li ul td tr tbody table p here for a quick overview of the site Help Center Detailed relatedl answers to any questions you might have Meta c preprocessor print define value Discuss the workings and policies of this site About Us Learn c preprocessor more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack gcc preprocessor print Overflow Questions