Please review a fix for 8007748: MacOSX build error : cast of type 'SEL' to 'uintptr_t' (aka 'unsigned long') is deprecated; use sel_getName instead

David DeHaven david.dehaven at oracle.com
Wed Feb 13 09:32:29 PST 2013


SEL is defined thusly:
typedef struct objc_selector     *SEL;

I would have a hard time believing Apple could change that without breaking everything that's currently written in Objective-C. The opaque parts could change, which is likely why the warning is showing up, or maybe they're just enforcing better coding practices.

-DrD-

> The code can run into a problem if Apple change the underlying type of SEL to something completely different (and larger) than a void* pointer. However, I think this is unlikely to happen.
> 
> The evaluation sounds reasonable to me, so consider the fix reviewed.
> 
> --
> best regards,
> Anthony
> 
> On 02/09/13 02:10, Phil Race wrote:
>> People building with the latest xcode seem to be hitting the error in
>> the subject line.
>> I think the error message is misleading about the solution and I propose
>> the fix below.
>> Does it look OK ?
>> I'm not really sure where to send this for review but I think the porting
>> alias is likely to have more people who would know what is right than
>> any of the other lists.
>> 
>> Here's a pointer to the full bug
>> http://bugs.sun.com/view_bug.do?bug_id=8007748
>> 
>> diff --git a/src/macosx/native/jobjc/src/core/native/SEL.m
>> b/src/macosx/native/jobjc/src/core/native/SEL.m
>> --- a/src/macosx/native/jobjc/src/core/native/SEL.m
>> +++ b/src/macosx/native/jobjc/src/core/native/SEL.m
>> @@ -34,7 +34,7 @@
>> const char *selNameAsChars = (*env)->GetStringUTFChars(env, selName,
>> JNI_FALSE);
>> const SEL sel = sel_registerName(selNameAsChars);
>> (*env)->ReleaseStringUTFChars(env, selName, selNameAsChars);
>> - return ptr_to_jlong(sel);
>> + return ptr_to_jlong((void*)sel);
>> }
>> 
>> JNIEXPORT jstring JNICALL Java_com_apple_jobjc_SEL_getSelectorName



More information about the macosx-port-dev mailing list