E
erichain
If I define global variables with the same name in different files,
what will the linker say according to the C standard(s)?
And can variable and function have the same name?
And is the main() function very special?
Thanks in advance!
e.g.
/* file1.c */
int a;
int b = 0;
int c = 1;
int d;
int e = 5;
int f = 6;
int func1;
int func2;
int f(void)
{
return 1;
}
int main(void)
{
f;
f();
func1;
func1();
func2;
func2();
return 0;
}
/* file2.c */
int a;
int b = 0;
int c = 2;
double d;
double e = 5.0;
double f = 6.6;
int main;
int func1(void)
{
return 2;
}
void func2(void)
{
}
what will the linker say according to the C standard(s)?
And can variable and function have the same name?
And is the main() function very special?
Thanks in advance!
e.g.
/* file1.c */
int a;
int b = 0;
int c = 1;
int d;
int e = 5;
int f = 6;
int func1;
int func2;
int f(void)
{
return 1;
}
int main(void)
{
f;
f();
func1;
func1();
func2;
func2();
return 0;
}
/* file2.c */
int a;
int b = 0;
int c = 2;
double d;
double e = 5.0;
double f = 6.6;
int main;
int func1(void)
{
return 2;
}
void func2(void)
{
}