2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
6 .. index:: diagnostic, reporting errors, reporting warnings, #error
13 The directive :samp:`#error` causes the preprocessor to report a fatal
14 error. The tokens forming the rest of the line following :samp:`#error`
15 are used as the error message.
17 You would use :samp:`#error` inside of a conditional that detects a
18 combination of parameters which you know the program does not properly
19 support. For example, if you know that the program will not run
20 properly on a VAX, you might write
25 #error "Won't work on VAXen. See comments at get_last_object."
28 If you have several configuration parameters that must be set up by
29 the installation in a consistent way, you can use conditionals to detect
30 an inconsistency and report it with :samp:`#error`. For example,
34 #if !defined(FOO) && defined(BAR)
35 #error "BAR requires FOO."
40 The directive :samp:`#warning` is like :samp:`#error`, but causes the
41 preprocessor to issue a warning and continue preprocessing. The tokens
42 following :samp:`#warning` are used as the warning message.
44 You might use :samp:`#warning` in obsolete header files, with a message
45 directing the user to the header file which should be used instead.
47 Neither :samp:`#error` nor :samp:`#warning` macro-expands its argument.
48 Internal whitespace sequences are each replaced with a single space.
49 The line must consist of complete tokens. It is wisest to make the
50 argument of these directives be a single string constant; this avoids
51 problems with apostrophes and the like.