Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Casting an NSError return to a CFErrorRef return

I have a function that returns an NSError object by reference:

NSData *foo(NSData *foo, NSError *__autoreleasing *outError);

This function uses an API that takes a pointer to storage for a CFErrorRef. I'd like to just pass outError to the underlying function directly, but I can't figure out the correct combination of declaration keywords and cast keywords to make clang agree with that plan. Is there one?

like image 223
Peter Hosey Avatar asked Oct 09 '22 05:10

Peter Hosey


1 Answers

If you look at the clang notes for __autoreleasing it mentions that the magic happens at assignment time, which means that automatic casting can't help here. You need to actually make the assignment using a temporary variable as mentioned in the comments on the original post.

like image 191
cobbal Avatar answered Oct 13 '22 10:10

cobbal