1
轉換無效我運行在.mm文件下面的代碼,我得到的錯誤:從常量無效*錯誤
Invalid conversion from 'const void*' to 'const __CFData*'
我需要在.mm運行代碼。如果我更改爲.m它不會抱怨。爲什麼它的行爲如此?我編譯到iPhone
CFSocketNativeHandle native;
CFDataRef nativeProp = CFReadStreamCopyProperty(theReadStream, kCFStreamPropertySocketNativeHandle);
if(nativeProp == NULL)
{
if (errPtr) *errPtr = [self getStreamError];
return NO;
}
CFIndex nativePropLen = CFDataGetLength(nativeProp);
CFIndex nativeLen = (CFIndex)sizeof(native);
CFIndex len = MIN(nativePropLen, nativeLen);
CFDataGetBytes(nativeProp, CFRangeMake(0, len), (UInt8 *)&native);
CFRelease(nativeProp);
CFSocketRef theSocket = CFSocketCreateWithNative(kCFAllocatorDefault, native, 0, NULL, NULL);
if(theSocket == NULL)
{
if (errPtr) *errPtr = [self getSocketError];
return NO;
}
指出錯誤發生的位置通常很有幫助。 –