1

I got this error, and as I program xcode only at my house, I have no resources to quickly ask even the most simple 10 second questions. So this is one that came up today, I am using the AudioSessionAddPropertyListener function, and I get this warning:

passing 'CFTypeRef' (aka 'const void ) to parameter of type 'void' discards Qualifiers

from this line of code.

// Registers the audio route change listener callback function
// An instance of the audio player/manager is passed to the listener
AudioSessionAddPropertyListener (  kAudioSessionProperty_AudioRouteChange, 
                                 audioRouteChangeListenerCallback,  CFBridgingRetain(self) );

then definition of the AudioSessionAddPropertyListener is

AudioSessionAddPropertyListener(    AudioSessionPropertyID              inID,
                                AudioSessionPropertyListener        inProc,
                                void                                *inClientData)  

and I see the *inClientData variable appears to be of type void (Or maybe not)

So what exactly might be the problem here, Mostly I would like to know what to look for when trouble shooting. I don't know what I don't know.

thanks

Steve

I'm not at 50 yet so I can't comment:

I looked at the definition of CFBridgingRetain it takes ID, and returns CFTypeRef

NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
    return (__bridge_retained CFTypeRef)X;
}

Now the definition of CFTypeRef is void /* Base "type" of all "CF objects", and polymorphic functions on them */ typedef const void * CFTypeRef;

so in order to drop the warning I did this, cast the output of the function as (void *)

AudioSessionAddPropertyListener (  kAudioSessionProperty_AudioRouteChange, 
                                 audioRouteChangeListenerCallback,  (void *) CFBridgingRetain(self) );

Does anyone see an issue with this?

SESPROUL
  • 241
  • 3
  • 8
  • check this topic [sending CFTypeRef (aka const void*) to parameter of type 'void *' discards qualifiers][1] [1]: http://stackoverflow.com/questions/17038376/sending-cftyperef-aka-const-void-to-parameter-of-type-void-discards-quali – MiguelSlv Aug 25 '13 at 14:21
  • I think you omitted `*` when you quoted the above message. It's important. – Hot Licks Aug 25 '13 at 14:27

0 Answers0