How to make this code compile?
Posted
by skydoor
on Stack Overflow
See other posts from Stack Overflow
or by skydoor
Published on 2010-03-25T20:52:02Z
Indexed on
2010/03/25
20:53 UTC
Read the original article
Hit count: 309
c
// File: foo.c
static int var;
void foo()
{
var++;
}
// end of file foo.c
// File bar.c:
static int var;
void bar()
{
var++;
}
// end of file bar.c
// file main.c
static int var;
void main()
{
foo();
bar();
printf("%d", var);
}
// end of file main.c
Question: Will the above program compile ? If so what will be the result ?
I tested the code and found it couldn't be compiled. I try to use extern in main.c to use the function foo() and bar() but it still couldn't be compiled.
© Stack Overflow or respective owner