pete said:
.... snip ...
For matched pairs of .c and .h files:
I am inclined not to put extern object declarations in a header.
I think they belong in the .c file.
If a.c used "extern struct e d", any other .c file linking with a.c,
wouldn't need to know which external objects were being used in a.c,
so therefore "extern struct e d",
should be declared in a.c, instead of in a.h.
You won't go wrong if you consider the .h file as a means of
publicizing those portions of the .c file you want to make
accessible to other compilation units. Thus you declare and
define the objects in the .c file. If the objects are NOT to be
accessible externally you mark them static. If they ARE to be
accessible externally you declare them in the .h file, and use the
extern keyword for objects other than function prototypes.
Similarly you put typedefs and macros in the .h file ONLY when you
need to have them available to other compilation units.
--
"I'm a war president. I make decisions here in the Oval Office
in foreign policy matters with war on my mind." - Bush.
"Churchill and Bush can both be considered wartime leaders, just
as Secretariat and Mr Ed were both horses." - James Rhodes.
"If I knew then what I know today, I would still have invaded
Iraq. It was the right decision" - G.W. Bush, 2004-08-02