I have three files and want to compile it.
The first file is app.c
#include"sum.h"
int main (void)
{
sum();
return 0;
}
The second files is sum.h
#ifndef SUM_H
#define SUM_H
void sum ();
#endif
and the third file sum.c
#include"sum.h"
void sum ()
{
return;
}
and I write these statements:
#ifndef SUM_H
#define SUM_H
...
...
...
#endif
to prevent the multiple definitions of the content of sum.h
.
During compiling the app.c
will enter the preprocessing stage and then sum.c
enter the preprocessing stage my question when the sum.c
enters how the preprocessor know that SUM_H
is defined in the last file of myapp?
I think that each source file enter the preprocessing stage and compiling stage individually.