file1.c
int a1;
int main()
{
a1 = 2;
printf("\na1 = %d\n", a1);
next();
printf("\na1 = %d\n", a1);
next1();
printf("\na1 = %d\n", a1);
}
file2.c
#include <stdio.h>
int b1 = 0;
void next(void)
{
char a1;
a1 = 'a';
b1 = 77;
}
file3.c
int a1;
void next1(void)
{
float b1;
b1 = 20.3;
a1 = 15;
}
When i compile it using gcc -c and create separate respective object file
-and try to link them it dosent give any errors as to "multiple declaration of variable" as of "variable a" in this case.
-And it gets comiled and linked successfully.
-also the "third printf" in file1.c prints the value of a=15 which is updated by file3.c.
-whereas its nowhere specified in file3.c that variable "a is an exterm variable"
in that case file1.c would printf the value of a1=15;
-so.................???????????????????????
Regards
Tanvir
Moved to High Level Programming Forum. FPMurphy