Re: !foo vs foo == nil
Re: !foo vs foo == nil
- Subject: Re: !foo vs foo == nil
- From: Thomas Engelmeier <email@hidden>
- Date: Thu, 21 Aug 2008 13:48:43 +0200
Am 21.08.2008 um 13:25 schrieb Chris Holloway:
If you look at section 7.17 of ISO/IEC 9899:1999, then it states that
NULL is a macro which "expands to an implementation-defined null
pointer constant". So, what is a null pointer constant? Section
6.3.2.3 states that "An integer constant expression with the value 0,
or such an expression cast to type void *, is called a null pointer
constant". So, in order for NULL to satisfy the requirement of being a
null pointer constant, it must be either 0 or (void *)0 (as Michael
stated), and hence (int)NULL is guaranteed to be 0.
What I meant was, as you noted correctly, that the memory pattern of
an NULL pointer is not necessary sizeof( void * ) bytes containing
0x00. Obviously I overlooked that the standard guarantees the
conversion NULL => int results in 0 and vice versa.
Regards,
Tom_E
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden