Consider a variable abulo. I am trying to share abulo between 2 .c files. Here is what I did --
- Created a.h . This file contains the line, extern int abulo;
- a.c contains a statement like this, int abulo = 0;
- in b.c, a.h has been included. Then there is just a kprintf function printing the value of yours.
But when I try to run the code it shows me an output like this --
undefined reference to `abulo'
Tried to use the idea of the accpeted answer given here - How do I share variables between different .c files?
what am I doing wrong here ? How to get rid of this error ?