I want to allocate space for CFString in a subfunction. Something like this:
void fun(CFStringRef *ref)
{
    ref = CFStringCreateWithCString(NUL开发者_Go百科L, "hi", kCFStringEncodingUTF8);
}
int main(void)
{
    CFStringRef ref;
    fun(&ref);
    CFShow(ref);
    if(ref) CFRelease(ref);
    return 0;
}
It does compile with a warning and doesn't print "hi". What's wrong here?
EDIT: added CFRelease()
CFStringCreateWithCString() returns a CFStringRef, not a CFStringRef *. You have to dereference the pointer in the assignment:
*ref = CFStringCreateWithCString(NULL, "hi", kCFStringEncodingUTF8);
Edit: for your next question, please don't just say "it compiles with a warning". Tell us the actual warning message. It makes answering your question so much easier.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论