Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective C and gcc problems



On Mon, Jun 18, 2001 at 02:53:24PM -0400, Andre John Mas wrote:
> I have just been following the tutorial in the "Learning Cocoa" book and
> had problems with the follow code:
>
> int main (int argc, const char * argv[])
> {
> NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
> NSMutableArray *myArray = [[NSMutableArray alloc] init];
>
> [myArray addObject: @"Here's a string"];
>
> int itemCount;

The problem is here. You need to declare your variables at the beginning of a block in C (and thus in Objective C as well).

Move int itemCount;

> the gcc version as provided by "cc -v" is: "Apple Computer, Inc. version
> gcc-926, based on gcc version 2.95.2 19991024 (release)".
>
> Who is right, the book or the compiler?

The compiler ... although if the book were right, you would still have to change your code so that you could actually use it ;-)

--
Daniel J. Luke
+========================================================+
| *---------------- email@hidden ----------------* |
| *-------------- http://www.geeklair.net -------------* |
+========================================================+
| Opinions expressed are mine and do not necessarily |
| reflect the opinions of my employer. |
+========================================================+


References: 
 >Objective C and gcc problems (From: Andre John Mas <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.