I agree with you, but I guess he missed semicolon just before an array
declaration because he got *compiler* error, not linker!
Correct declaration could be of two forms:
1) In header file
static int a[2] = {1,2};
or
static int a[] = {1,2};
2) In header file
extern int a[2];
In *.m file:
int a[2] = {1,2};
01-Jun-11 19:14, Ron Hunsinger пишет:
The problem is that while globals can be declared in as many compilation units
as you wish, they must be defined in only one. That means that a definition
cannot appear in a file that's #included into multiple compilation units.
It would be perfectly fine to put that initializer in a .h file, as long as the .h file is
#included into only one .c file. That's not how we normally use .h files, though, because it would
make the name visible in only the one compilation unit that included it. The whole point of having
separate .h and .c files is to work around the "declared in multiple units: OK, defined in
multiple units: BAD" limitation, without giving up the safety of "declared in multiple
source files: BAD"._______________________________________________
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com