I am wondering if an infinite loop of including files causes a compiler problem or a linker problem. I tried this :
/* file : try.c */
#include "try1.c"
int main(void) {}
/* file : try1.c */
#include "try.c"
int a(void) { return 0; }
The command to compile is :
gcc -Wall try.c -o try
This obviously causes a very long output (starts like this) :
try.c:5:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
In file included from try.c:1:0,
from try1.c:1,
from try.c:1:
try1.c:4:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
In file included from try1.c:1:0,
from try.c:1:
try.c:5:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
In file included from try.c:1:0:
try1.c:4:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
try.c:5:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
In file included from try.c:2:0,
from try1.c:1,
from try.c:1,
from try1.c:1,
from try.c:1,
from try1.c:1,
from try.c:1,
from try1.c:1,
from try.c:1,
from try1.c:1,
.
.
etc...
Well, obviously there is an infinite loop here. But when does it occur ? At the compiling process or the linker one? I think you are going to tell me at the compiling process because it will define here more than one function with the same name (because of the loop), but isn't the part that unite files occur at the linker process (And then there are no compilation problem for only one file) ?
Thanks !