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!

Sam Charette wrote in message <10191@palm-dev-forum>...
>
>I have a question for anyone who is willing to help me out in my time of
>utter confusion.
>
>I am doing a proof of concept (ergo little time for design, and therefor
>not very well structured) for a project and am having problems with
>certain global variables.
>
>In the main application header file I create global variables for each
>of the databases to be used by the application.  I use the:
>
>#ifndef <identifier>
>#define <identifier>
>#endif
>
>group in order to include the contents of my header files only once
>regardless as to how often it is included by other files.  I must,
>however, for some reason declare my globals as static since if I don't I
>get multiple definition errors.
>
>Now, I have 3 different files accessing these globals.  Two of them work
>fine, one does not.  When I get to that file the database variable being
>used seems to have been reset and so I get a rather nasty error when I
>try to access it with the DmNumRecords function.
>
>I really don't understand why the linker thinks there are multiple
>declarations of these variables if not set static, and I do not
>understand why two of the files would work and one would not.  They all
>have the proper headers included...
>
>Any help would be greatly appreciated!
>
>Sam Charette
>
>
>



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