Well, all of the globals were in only one file, but it was the extern keyword I was 
fishing for.  I do have a question tho... many
people have said nearly the same as you, but you and someone else said it slightly 
differently.

What I ended up doing was this:

<headerfile>.h

#ifndef MYHEADER
#define MYHEADER
int     myVariable;
#endif

<end headerfile>

<any module file>.c

#include "<headerfile>.h"

extern int    myVariable;

<end module file>

You seem to have the extern in the header xyzzy.h, a redeclaration in xyzzy.c and 
nothing in plugh.c.  You are not the only one to
have the extern in the header instead of the module files... is there something more 
subtle about the use of extern that I am
missing?

Sam


"Richard M. Hartman" wrote:

> your problem is that you havce more than one .c (or .cpp) file
> including your .h files.  each will be declaring them.  if they
> are declared static, then each will have their own copies.
>
> you must pick a file in which to declare your globals -- one
> and one only.
>
> try this:
>
> xyzzy.h:
>
> extern int global;
>
> xyzzy.c:
>
> #include "xyzzy.h"
>
> // declare globals for module "xyzzy"
> int global=3;
>
> plugh.c:
>
> #include xyzzy.h
>
> // we can use "global" here...
>
> --
> -Richard M. Hartman
> [EMAIL PROTECTED]
>
> 186,000 mi/sec: not just a good idea, it's the LAW!
>


-- 
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