Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. Input/Output statements
  5. Pre-processor directives
  6. Error directive

Error directive

The error directive causes the preprocessor to generate customized diagnostic messages and causes the compilation to fail.

The error directive has the following forms,

#error

This directive causes the preprocessor to issue an error without any message.

#error token

This directive causes the preprocessor to issue an error message that indicates the text specified by the token sequence

Example

#include<stdio.h>
#error this is a customized error message
int main()
{
	printf("use of error directive");
	return 0;
}

Output

error.c:2:2: error: #error this is a customized error message
#error this is a customized error message

Views: 0

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments