Henk Jonas wrote:
Asanka Hewage wrote:
Let's consider 2 files, first.c and second.c. I need a global variable
for both these files. Is it Possible??????????????
If it's possible please send me some code samples.
Thank
Asanka.
file 1: int g_Variable;
file 2: extern int g_Variable;
To avoid type errors and stuff, I find it works well to put
extern int g_Variable;
in foo.h and then
int g_Variable;
in foo.c. Then in any other file that wants to use the variable,
just do
#include "foo.h"
Since you also #include foo.h in foo.c, the compiler can verify
that the two declarations have the same type.
- Logan
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/