preprocessor directives in c

Before a C program is compiled in a compiler, source code is processed by a program called preprocessor. This process is called preprocessing.

Commands used in preprocessor are called preprocessor directives and they begin with ”#” symbol. Below is the list of preprocessor directives that C language offers.

1 Macro
This macro defines constant value and can be any of the basic data types.

2 Header file inclusion 
#include <file_name>
The source code of the file ”file_name” is included in the main program at the specified place

3 Conditional compilation
#ifdef, #endif, #if, #else, #ifndef
Set of commands are included or excluded in source program before compilation with respect to the condition

4 Other directives 
#undef, #pragma
#undef is used to undefine a defined macro variable.
#Pragma is used to call a function before and after main function in a C program


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s