• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: OK to talk about 3.2.2+ and new compiler?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OK to talk about 3.2.2+ and new compiler?


  • Subject: Re: OK to talk about 3.2.2+ and new compiler?
  • From: "Paul Sanders" <email@hidden>
  • Date: Tue, 22 Jun 2010 10:25:36 +0100

> Is there an option that we can enable to force the compiler to emit warnings any time we make
> assignments to untyped classes?  I really hate the fact that mistakes like these are so simple to make.
 
I don't believe there is, no.  You could however define a macro along these lines:
 
    #define ALLOC_OBJECT(cls, ini, ...)  (cls *) [((cls *) [cls alloc]) ini, ## __VA_ARGS__]
 
And then you can do this:
 
    MySuperDuperClass *obj = ALLOC_OBJECT (MySuperDuperClass, init);
    [obj autorelease];
 
Or this:
 
    MySuperDuperClass *obj = ALLOC_OBJECT (MySuperDuperClass, initWithX: x Y: y);
 
Or even this:
 
    MySuperDuperClass *obj = ALLOC_OBJECT (MySuperDuperClass, initWithObjects: obj1, obj2, nil);
 
The nice thing about this approach is that you can adapt your source code piecemeal.
 
The second, interior cast is in there to disambiguate initxxx methods if two different classes happen to define the same method signature.  There was a thread about this on cocoa-dev a couple of months ago.  It doesn't happen often but it can be confusing - or even downright dangerous - when it does.
 
http://www.mail-archive.com/email@hidden/msg56580.html
 
GCC's extended support for variadic macros is rather nice, is it not?
 
Regards,
 
Paul Sanders.
 
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >OK to talk about 3.2.2+ and new compiler? (From: Paul Summermatter <email@hidden>)
 >Re: OK to talk about 3.2.2+ and new compiler? (From: Roland King <email@hidden>)
 >Re: OK to talk about 3.2.2+ and new compiler? (From: Paul Summermatter <email@hidden>)

  • Prev by Date: Re: Another subversion dilemma
  • Next by Date: Xcode 3.2.2 CONFIGURATION_TEMP_DIR build setting makes build fail
  • Previous by thread: Re: OK to talk about 3.2.2+ and new compiler?
  • Next by thread: Re: OK to talk about 3.2.2+ and new compiler?
  • Index(es):
    • Date
    • Thread