Automatic (Function Scope) Variables

A variable declared within a function can only be used within the scope of that function.

MAIN.CPP

void test(void);

static int lnktest3 =3;
int lnktest4 =4;

void main()
{
 static int lnktest1 =1;
 int lnktest2 = 2;
 test( );
}

TEST.CPP

extern int lnktest1;
extern int lnktest2;
extern int lnktest3;
extern int lnktest4;

void test(void)
{
  int i =0;
   i = lnktest1;   //causes LNK2001 reason b
   i = lnktest2;   //causes LNK2001   reason b
   i = lnktest3;   //causes LNK2001 reason a
   i = lnktest4;   // OK  
}