Programming Reference/Librarys
Question & Answer
Q&A is closed
#error your error_message
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
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