problem with extern variable
- by sksingh73
I have got 2 cpp files & a header file, which I have included in both cpp files. It's like this:
abc.h
extern uint32_t key;
a.cpp
#include "abc.h"
uint32_t key;
int main
{
.............
}
b.cpp
#include "abc.h"
int main
{
printf("Key: %.8x\n", key);
.............
}
Now when I compile a.cpp, there is no error. but when i compile b.cpp it gives error
"undefined reference to `key'". Please help me in finding the problem in this code.