The problem with declaring storage within a header file is that it introduces the possibility of multiple-definition errors. I recommend declaring "
d" as external to prevent multiple-definition errors. For example:
Header File A:
1 2 3 4 5 6
|
#if !defined HEADER_A
#define HEADER_A
extern int Integer;
#endif
|
Source File A:
1 2 3
|
#include Header File A
int Integer;
|
In the implementation of Header A, "
extern" basically means that "
Integer" is defined elsewhere. It doesn't matter where "
Integer" is defined, so long as it's within a source file. So when ever you include a header file multiple times, the compiler knows that all references to "
Integer" will be redirected to "
Integer" within the source file where it was initially declared.
In conclusion, don't declare any type of storage within header files unless it's static (the storage will become available only to the file in which the storage was declared). If you have to declare a piece of storage within a header file, it should be declared "
extern" and the actual declaration should be within a source file somewhere.
Wazzak