This has nothing to do with #ifdef

You simple need to have a global variable
without storage class, while in all other modules
you need extrn

Here the way you may do it

In MyHeader.h you have

#ifdef MAIN
#define global 
#else
#define global extern
#endif

global int var1, var2;
global char var3;

-------------------------------------
In the main module you have

#define MAIN
#incliude "MyHeader.h"

in other modules you don't put #define MAIN


Michael



-----Original Message-----
From: Sandra Webb [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 28 November 2001 12:33 PM
To: Palm Developer Forum
Subject: #ifndef...


I assumed that when you used:

#ifndef MyHeaderFile
#define MyHeaderFile
...
#endif

... whatever is inside the define would only be defined once, no matter how
many files have that header in it.  I have a project where I have split it
up into several files, each with their own header.  Now, I have put in the
headers the #ifndef code, however, if I don't make the variables static, I
get a linker error that says the variable is already declared another file
(the first file compiled with the header included).  It seems to me that
ifndef is not working.  Or maybe is that the way it is supposed to work?  If
so, than how can I use my header file to share a variable between two
different files?  If I leave it static, then the second file does not get
the information.  Do I just have to move to one huge header file?

Any help on this would be greatly appreciated.  Thank you very much.

Sandra Webb



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

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