springframework
Mar 31, 2008, 08:56 PM
so i made a header file Global.h
extern int gVar;
inside main.m
int gVar;
int main( ... ){
gVar = 5;
... // more code
}
inside another .m file
#include Global.h
gVar = 88;
inside yet another .m file
#include Global.h
NSLog( ... , gVar); // expected output 88
This wont compile ....
By simply taking out "extern", it works with expected output of 88.
My variable seems to be global without using extern?
Is my variable truely global? it has to be ... it prints out 88.
Does anyone know a better way to do global variables?
I plan on having NSMutableArray/NSXMLDocument global variables. will the way im doing it work with these more advanced data structures?
extern int gVar;
inside main.m
int gVar;
int main( ... ){
gVar = 5;
... // more code
}
inside another .m file
#include Global.h
gVar = 88;
inside yet another .m file
#include Global.h
NSLog( ... , gVar); // expected output 88
This wont compile ....
By simply taking out "extern", it works with expected output of 88.
My variable seems to be global without using extern?
Is my variable truely global? it has to be ... it prints out 88.
Does anyone know a better way to do global variables?
I plan on having NSMutableArray/NSXMLDocument global variables. will the way im doing it work with these more advanced data structures?
