Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mach_port_t



In message <email@hidden>, Garth Cummings wri
tes:
>The main thing that changed is that the C standard now defines NULL  
>as (void *) 0. Earlier versions of the language did not specify a  
>value for NULL and most implementations defined NULL as 0.

The C standard has defined NULL the same way since 1989; it is either
an integer constant expression equal to zero, or the same cast to (void *).
(Formally, "an implementation-defined null pointer constant.")

What I don't understand is why something that has always been essentially
a pointer thing (even if it wasn't always implemented that way) has been
used for things that aren't pointers.

>Converting a pointer to an integer is legal but non-portable: the  
>result is implementation-defined.

Yes.

>You'd have to ask the authors of the code. :-) My guess is that NULL  
>was just convenient. More strictly correct would be MACH_PORT_NULL.  
>Tiger also introduced IO_OBJECT_NULL as ((io_object_t) 0).

>Tiger was built (mostly) with gcc 3.3. As Mac OS X moves to being  
>built with gcc 4.0, I would expect these warnings to be cleaned up.

Okay, that makes sense.

>In the I/O Kit master port case, since Jaguar there's been the  
>constant kIOMasterPortDefault. Just pass that to any call that needs  
>the I/O Kit master port, and you no longer need to call IOMasterPort 
>() explicitly.

I was just using the example code for the HID driver stuff.

Anyway, MACH_PORT_NULL and IO_OBJECT_NULL seem like good matches.

-s
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: mach_port_t (From: Garth Cummings <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.