Date: Fri, 29 May 1998 08:21:15 +1000 From: Bruce Evans <bde@zeta.org.au> To: bde@zeta.org.au, dag-erli@ifi.uio.no Cc: current@FreeBSD.ORG, eivind@yes.no, rnordier@nordier.com Subject: Re: Replacing gcc as the system compiler Message-ID: <199805282221.IAA06688@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>> The standard doesn't allow conversion from an object pointer to a
>> function pointer, but (void *)0 is is a null pointer constant and
>> null pointer constants are special.
>
>The C null pointer constant is 0. No cast is needed. Converting 0 to a
Not quite. 0 is one of many C null pointer consants.
>function pointer might work better than converting ((void *)0).
Only in not-quite-C. In C, they work identically when correctly used,
and break differently when incorrectly used.
>The only situation in which it is advantageous to define NULL as
>((void*)0) instead of just (0) is when passing NULL to a vararg
>function which lacks a prototype; but you shouldn't do that anyway,
>because it will break on more than just NULL (float->double conversion
>for instance)
This is actully the main disadvantage defining NULL as ((void *) 0) :-)
- it helps broken program work.
>With the correct prototypes, it is perfectly legal and semantically
>correct to write e.g.
>
> execl("/bin/sh", "-sh", 0);
Read what you wrote in the previous paragraph. execl() is varargs, so
its varadic parameters must not be uncast 0s or NULLs.
Bruce
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199805282221.IAA06688>
