[Date Prev][Date Next]
RE: nonstandard assumptions in the code
Howard Chu writes:
>>>> * can cast function pointers to 'void *' and back
>>>> (at least the threading stuff)
> K&R 2nd Edition (ANSI C) p.120 "Any pointer can be cast to void * and back
> again without loss of information."
This does not apply to function pointers. There have been plenty of
threads about this on comp.std.c and comp.lang.c. Some cite real-world
Formal reason: ANSI 188.8.131.52 says 'A pointer to any INCOMPLETE OR OBJECT
TYPE may be converted to a pointer to void and back again; the result
shall compare equal to the original pointer.'
However, a function is not an object.
>> Another non-ANSI thing: LBER_OPT_ON and LDAP_OPT_ON are #defined as
>> ((void*)1). There is no guarantee that this is != NULL (the *_OPT_OFF
>> options). I'll install this fix unless someone protests:
> K&R 2nd Edition p.102 - NULL is zero, by definition. Also stated again
> in section 184.108.40.206 of the C90 spec.
Not quite. NULL is a null pointer constant, and a null pointer constant
is _spelled_ 0 or (void*)0. But that doesn't mean that some other
integer cast to void* can't compare equal to NULL. The result of
casting integers (other than the constant 0) to pointers is