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:
Here is my code:/tmp/ccKsh4uo.o: In function `myFunction':
test.c: (.text+0x5): undefined reference to `testVar'
collect2: ld returned 1 exit status
Code:// File: test.h extern char testVar;Any ideas why this would happen?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; }



LinkBack URL
About LinkBacks



