• 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: ARC and reinterpret_cast?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ARC and reinterpret_cast?


  • Subject: Re: ARC and reinterpret_cast?
  • From: Andreas Grosam <email@hidden>
  • Date: Mon, 09 Jul 2012 09:09:50 +0200

On 08.07.2012, at 06:13, Rick Mann wrote:

> Hi. I'd like to write code like this:
>
> 	MyObject* foo = reinterpret_cast<__bridge MyObject*> (someVoidPointer);
>
> But the compiler doesn't like it. It's perfectly happy with:
>
> 	MyObject* foo = (__bridge MyObject) someVoidPointer;
>
> this is in a .mm file.

You probably meant this (without typo):
> 	MyObject* foo = (__bridge MyObject*) someVoidPointer;

I think, the assumption that __bridge is a simple type qualifier (like const or volatile) is false. It's rather a type conversion operator returning an object akin to an instance of a non-POD type.



What you are seeking for would be probably this:

MyObject* foo = __bridge_cast<MyObject*>(someVoidPointer);

But this doesn't exist - unless you define it yourself   ;)


Andreas

>
> The error is:
>
> error: type name requires a specifier or qualifier
>        MyObject* me = reinterpret_cast<__bridge MyObject*> (inRefCon);
>                                        ^
> error: expected '>'
>        MyObject* me = reinterpret_cast<__bridge MyObject*> (inRefCon);
>                                        ^
>>
> note: to match this '<'
>        MyObject* me = reinterpret_cast<__bridge MyObject*> (inRefCon);
>                                       ^
> Is it a bug in the compiler, or am I doing something wrong?
>
> TIA,
> --
> Rick
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >ARC and reinterpret_cast? (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Bottom-edge constraint not enforced in IB but is in runtime?
  • Next by Date: One more try - NSCollectionView multi-selection problem..
  • Previous by thread: ARC and reinterpret_cast?
  • Next by thread: Binding from document to app delegate?
  • Index(es):
    • Date
    • Thread