Compiling using gcc
I am working on a project that has some modules that will share a common handler. So I am using a extern
I have created a cut down version of my project.
However, I get an undefined reference hLibrary in library.c.
Is this the correct way to do this using extern. Or is there a better way to share a global that is safer?
#endif // LIBRARY_H_INCLUDED
extern int hLibrary;
printf("The library has been opened");
//Set the value for this handler so it can be
//used in another module (adapter.c)
hLibrary = 1010;
The module implementation file that will use the hLibrary handler.
#endif // ADAPTER_H_INCLUDED
if(hLibrary == 1010)
printf("\nAdapter has been started: %d", hLibrary);
printf("\nCould not find hLibrary");