The include directive is used to include files like as we include header files in the beginning of the program using #include directive like
It is used to assign names to different constants or statements which are to be used repeatedly in a program. These defined values or statement can be used by main or in the user defined functions as well.
# is called stringize opertor and turns the argument it precede into a quoted string. Use of # is shown in the C Source code given below and should be properly studied.
The preprocessor will include whatever file you specify in your #include statement. Therefore, if you have the line
in your program, the file macros.inc will be included in your precompiled program. It is, however, unusual programming practice to put any file that does not have a .h or .hpp extension in an #include statement. You should always put a .h extension on any of your C files you are going to include. This method makes it easier for you and others to identify which files are being used for preprocessing purposes.</macros.inc>
In modular programming, using functions is advisable when a certain code is repeated several times in a program. However, everytime a function is called the control gets transferred to that function and then back to the calling function. This consumes a lot of execution time. One way to save this time is by using macros. Macros substitute a function call by the definition of that function. This saves execution time to a great extent.
The #pragma Directives are used to turn ON or OFF certain features. They vary from compiler to compiler.
A macro is a preprocessor directive that provides a mechanism for token replacement in your source code. Macros are created by using the #define statement. Here is an example of a macro:
#define VERSION_STAMP "1.02"
The typedef clause can be used in a similar manner.
typedef long int int32; /* 32 bit signed integer */
The typedef is preferred over the #define because is better integrated into the C language, and it can create more kinds of variable types than a mere define.
Functions allow for modular programming. You must remember that all parameters passed into function in C are passed by value!