Pre-processors in C :
Pre-processors are one of the powerful tools of c programming language. These are the instructions which are performed by the compiler before actual compilation.
All the pre-processor directives command are written beginning with #. # is used to differentiate a pre-processor directive from rest of the programming code.
Following are the pre-processors directives used in c :
This instructs to include the header files in a program(copy the code of header file into another file).
This searches for file in standard library of c.
This searches for file in a current directory as well as standard library.
It is used to define a constant and macros in a c programming.
#define token value
#define PI 3.14
It replace PI with 3.14 wherever written in program.
This are used to undefine the constants and macros. It limits the scope of the constants and macros defined by define preprocessor.
ifdef & endif :
ifdef includes the code between endif or else and itself if the macro is defined. endif ends the conditional preprocessor.
ifndef includes the code between endif or else and itself if the macro is not defined. endif ends the conditional preprocessor.
if & else :
if tests for compile time condition and else is for its alternative.
It represents else and if staements in a combined form. It gives nested if else.
It is used to display error message.
It is used to issue some compiler specific command.
#pragma startup function1()
#pragma end function2()
The above two lines will run function1() at just start of main() and function2() just before end of main().