Re: Declaring and initialization of C array.

2011-06-02 Thread Vyacheslav Karamov
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

Re: Declaring and initialization of C array.

2011-06-01 Thread Ron Hunsinger
On Jun 1, 2011, at 8:17 AM, Graham Cox wrote: > > On 02/06/2011, at 1:12 AM, JAMES ROGERS wrote: > >> K&R says to declare and initialize an array in C: >> >> int myArray[2] = {1,2}; >> >> If the above is entered into the .h file > > > That's because a .h file is the HEADER. > > You ne

Re: Declaring and initialization of C array.

2011-06-01 Thread Wim Lewis
On 1 Jun 2011, at 8:17 AM, Graham Cox wrote: > On 02/06/2011, at 1:12 AM, JAMES ROGERS wrote: >> K&R says to declare and initialize an array in C: >> >> int myArray[2] = {1,2}; >> ArrayTestAppDelegate.h:14: error: expected ':', ',', ';', '}' or >> '__attribute__' before '=' token If I cop

Re: Declaring and initialization of C array.

2011-06-01 Thread John Joyce
>> K&R says to declare and initialize an array in C: >> >> int myArray[2] = {1,2}; >> >> If the above is entered into the .h file > > > That's because a .h file is the HEADER. > > You need to put this in the BODY, which is the .c (pure C) or .m (Obj-C) > file. The reason is that the = {1

Re: Declaring and initialization of C array.

2011-06-01 Thread Graham Cox
On 02/06/2011, at 1:12 AM, JAMES ROGERS wrote: > K&R says to declare and initialize an array in C: > > int myArray[2] = {1,2}; > > If the above is entered into the .h file That's because a .h file is the HEADER. You need to put this in the BODY, which is the .c (pure C) or .m (Obj-C) f

Declaring and initialization of C array.

2011-06-01 Thread JAMES ROGERS
K&R says to declare and initialize an array in C: int myArray[2] = {1,2}; If the above is entered into the .h file of a cocoa project, the compile will fail with the following: /Users/jimrogers_w4atk/Development/workspace/ArrayTest/ArrayTestAppDelegate.h:14:0 /Users/jimrogers