This issue is explained very well in the Harbison and Steele reference book on C. 
Different compilers use different rules. This is their advice (which I've followed 
successfully using CodeWarrior's compiler for Palm OS):

1. Have a single definition point (source file) for each external variable. In the 
defining declaration, omit the "extern" and include an explicit initializer:

        UInt16 FishCount = 0;

2. In each source file or header file referencing an external variable declared 
elsewhere, use "extern" and do not include an initializer:

        extern UInt16 FishCount;

My further piece of advice is to satisfy (2) above by putting this extern declaration 
in one header file that is included wherever it is needed. The header file should be 
the ".h" file that corresponds to the ".c" file in which the variable is defined (1). 
So, for example, you might put (1) above in Fish.c and (2) in Fish.h.

The term "fish" above is a contrived example.
--
Peter Epstein
Palm Inc. Developer


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to