I required to share a const value between two files; so rather than keeping a magical number I decided to use a const variable.
So I created a global variable const int viewTag = 100; in my appDelegate.m
Then accessed it as extern const int viewTag; but I got following linker error:
Undefined symbols for architecture i386:
"viewTag", referenced from:
-[xxxViewController launchxxx] in libxxx_iPad.a(xxxViewController.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
But the above thing is perfectly leagal in normal C,C++ env. can anybody throw some light?
Update: putting extern const int viewTag; in header and importing that header works, but I really don't want to do that for a single const int
Try putting:
extern const int viewTag;
in appDelegate.h, then importing this header where you need access to viewTag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With