Hello, I've come across an interesting problem I haven't had before.
Here is an example:
I have a variable called testVar which should be available to any .c file that #includes test.h. For some reason though I receive this error:
/tmp/ccKsh4uo.o: In function `myFunction':
test.c: (.text+0x5): undefined reference to `testVar'
collect2: ld returned 1 exit status
Here is my code:
Code:
// File: test.h
extern char testVar;
Code:
// File: test.c
#include <stdio.h>
#include "test.h"
void myFunction()
{
testVar = 'b';
}
int main()
{
char testVar = 'a';
myFunction();
printf("%c", testVar);
return 0;
}
Any ideas why this would happen?