简体   繁体   中英

Using LLVM GCC 4.2 won't let me _bridge a CFStringRef into an NSString

I need to do some graph plotting in my iPad app, so I've followed this tutorial:

http://recycled-parts.blogspot.com/2011/07/setting-up-coreplot-in-xcode-4.html

In which I had to change my C/C++/Objective-C Compiler to LLVM GCC 4.2. (Originally it was Apple LLVM Compiler 3.0).

Now, I'm unable to _bridge cast a CFStringRef into an NSString. I get the following error:

'_bridge' undeclared (first use in a function)

Can anyone help me sort this out?? Thanks.

The keyword __bridge has two leading underscores.

Guessing at your code this is probably similar to what you want:

CFStringRef cf = CFSTR("test");
NSString *ns = (__bridge_transfer NSString *)cf;

(It is a simple minded example given the constant string)

CocoaFu spotted one problem.

Another problem is that GCC+LLVM does not support ARC -- only Clang releases since summer 2011 support ARC. Bridged casting complements ARC.

If you need GCC, you will need to add manual reference counting to the program, or you could move things to separate files for your ARC/MRC differences. Or you could use earlier releases of your dependent libraries, if they are the ones which require ARC. Or... (a few more options)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM