Tuesday 20 June 2023

The C Preprocessor in C language

What is C Preprocessor?

In writing first C program or plan, you learned or take in how to use the #include preprocessor or initialization directive to include C header files. Since then, the #include instruction or directive has been used in every plan or program.

C preprocessor, c language, c language basics
C Preprocessor image-1

1.1   C Preprocessor

If there is a constant or continuous appearing in several or some places in your program, it’s a good idea to link or associate a figurative or symbolic name to the continuous or constant, and then use the symbolic or figurative name to replace the constant all over or throughout the program. There are two upper hands or advantages in doing so. First, the plan or program will be more clear or readable. Second, it’s effortless or easier to maintain plan or program. For occasion or instance, if the values of the constant needs to be switch or changed, find the declaration or statement that link or associates the constant with the figurative or symbolic name and replace the sustained or constant with the new one. Without using the figurative or symbolic name, you have to look everywhere in your plan or program to replace the constant.

 

C has a particular or special program or plan called the C Preprocessor that allows computer specialist or programmers define and link or associate symbolic names with continuous or constants. In fact, the C preprocessor uses the expressions or terminology macro names and macro body to refer to the figurative or symbolic names and the continuous or constants. The C preprocessor or initialization runs before the compiler. During preprocessing, the working or operation to replace a macro name with its link or associated macro body is called macro substitution or macro expansion or growth.

 

In addition, the C preprocessor or initialization gives you the capacity to include other source files. For instance, we’ve been using the preprocessor command or directive #include to include C header files, such as stdlib.h, stdio.h, and string.h, in the plan or programs. Also, the C preprocessor or initialization enables to compile or organize different sections of program or plan under specified conditions.

1.2   The C Preprocessor Versus the Compiler

One major or important thing need to recollect or remember is that the C preprocessor is not part of the C compiler.

The C preprocessor uses a unlike or different syntax. All directives or instruction in the C preprocessor begin with a pound sign (#). In other words, the pound sign indicate or denotes the beginning of a preprocessor or initialization directive, and it must be the first non space nature or character on the line. The C preprocessor is line place or oriented. Each macro statement or declaration ends with a new line character or nature, not a semicolon. (Only C statements end with semicolons.) One of the most common or usual mistakes made by the programmer is to place a semicolon at the end of a macro statement. Fortunately, many C editor or compilers can catch such errors.


Computer stuff kit tricks of Topics 63.