You do not need to use underscore, this is just an agreement to separate the header name and extension. You cannot use a literal . , since this is not valid in the identifier, so you replace it with an underscore that is valid.
The reason you actually do this is to turn on the guard. The entire contents of the file look something like this:
#ifndef PENCERE_H #define PENCERE_H
so that if you accidentally turn it on twice:
#include "pencere.h" #include "pencere.h"
you will not get everything that is duplicated in it. Double inclusions are usually finer than this, for example, you can include pax.h and diablo.h in your code, and pax.h also includes diablo.h for your purposes:
main.c: #include "pax.h" #include "diablo.h"
In this case, if there were no guards enabled, try compiling the string typedef int mytype; twice in your program. Once for main.c -> pax.h -> diablo.h and again for main.c -> diablo.h .
With guards turned on, the pre-processor DIABLO_H is defined when main.c turns on diablo.h , so #define and typedef not processed.
This particular mapping of header files to #define names breaks down in a situation where you have dir1/pax.h and dir2/pax.h , since they will use PAX_H . In this case, to solve the problem, you can use a circuit of the type DIR1_PAX_H and DIR2_PAX_H .
source share