The #error directive is one of the C preprocessor directives whose purpose is to stop the compilation process when a violation of constraint is found.
This program demonstrate the use of #error directive in Turbo C++ that is running on a DOS Box 0.74 system running on a Windows 7 64-bit PC.
In this program, we are trying to write a program for finding q square-root of a number. To find square root we need a function called sqrt() which is part of Math.h header file.
The header file is not included in the programming which is an error. The #error directive will find this error and throw a user-defined message before terminating the compilation process.
Program Code – #error
Output – #error directive
The output from the program is a compilation error – #error directive in turbo C++ compiler.
First include header file then compile