#include "header.h" int main (void)
{
puts (test ());
}
and the compiler will see the same token stream, when the program.c program reads as follows:
int x;
char * test (void); int main (void)
{
puts (test ());
}
If the file header is included twice, the compiler will report an error and print an error. The standard way to avoid this case is to use conditional expressions as follows:
ifndef HEADER_FILE
#define HEADER_FILEthe entire header file file # endif
In case it is already included, the above program will not include it again.
Sometimes you need to choose one of the headers to include in the program, you must have the operating system configuration parameter to use. You can do this with a range of conditions as follows:
if SYSTEM_1
# include "system_1.h"
#elif SYSTEM_2
# include "system_2.h"
#elif SYSTEM_3
.
#endif
But when this number of conditions is many, it becomes tedious, instead the preprocessor provides the ability to use a macro for the Header name. This is called Conditional Include . Instead of writing a Header name as the direct parameter of #include , you simply put a macro name there instead of it:
define SYSTEM_H "system_1.h"
.
#include SYSTEM_H
SYSTEM_H will be expanded, and the preprocessor will search for system_1.h if #include has been written that way initially. SYSTEM_H can be defined by the file you create with -D option.
According to Tutorialspoint
Previous article: The preprocessor in C
Next lesson: Press type in C