I am trying to use a variable I have already declared on a .h file on a .c file and i gives me a compile error:
undefined reference to
var
this is the mach.c content:
#include "machheader.h"
int
main( void )
{
var = 1;
printf("Variable %d\n", var);
}
And my machheader.h contains only this:
extern int var;
Any idea?
In your case,
extern int var;
is a declaration, not a definition. You need to have a definition of var
in your code.