User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:preprocessor:error
click
to support this page (eg 0,42 € or so) Thanks.

error

#error your error_message

description of error

The #error directive emits a user-specified error message at compile time and then terminates the compilation. The following code will cause in compilation error:

#include<stdio.h>
 
int main()
{
    printf("code-reference.com/c");
 
    return 0;
}
 
#if !defined(PASS_COMPILER)
#error Syntax to Pass this stage is required !
#endif

The following code will compile:

#define PASS_COMPILER      /*You can write this definition here or any*/ 
#include<stdio.h>
 
int main()
{
    printf("code-reference.com/c");
 
    /*#define PASS_COMPILER*/
 
    return 0;
}
 
#if !defined(PASS_COMPILER)
#error Syntax to Pass this stage is required !
#endif

output of error c example

In first program: No output, because “PASS_COMPILER” is not defined in program, so compilation terminates with Error Message as shown: “\main.c|4|error: #error Syntax to Pass this stage is required !|”

In the Second program: Output will be:

code-reference.com/c
advertising
c/preprocessor/error.txt · Last modified: 2013/10/23 16:23 by Awad A. Bekhet

Impressum