Is there a NULL pointer to functions?

Christopher R Volpe volpe at camelback.crd.ge.com
Wed May 29 14:16:32 AEST 1991


In article <748 at taumet.com>, steve at taumet.com (Stephen Clamage) writes:
|>bhoughto at pima.intel.com (Blair P. Houghton) writes:
|>
|>>In article <1991May21.125639.10052 at umiami.ir.miami.edu>
devebw9f at miavax.ir.miami.edu writes:
|>
|>>>#define NULL ((void *) 0)
|>>>void  foo (void (*fun) (void))
|>>>{
|>>>      if (fun != NULL)            /* Line with the warning. */
|>>>           ...
|>>>warning: ANSI C forbids comparison of `void *' with function pointer
|>
|>>Use a cast to get the correct type in the right-hand operand:
|>
|>>	if ( fun != (void (*) (void))NULL )
|>
|>This isn't really the best solution.  NULL as defined in the standard
|>ANSI headers is a pointer to an object (data), not pointer to a function.

Is it really defined as a pointer to an object? I always see it defined
as a "null pointer constant", (either "0" or "(void *) 0"), which is 
comparable to any pointer type, no? Section 3.2.2.3 says that a null-pointer-
constant (and "(void *)0" is in fact a null pointer constant) can be assigned
to or compared for equality to any pointer, including function pointers.

                                       
==================
Chris Volpe
G.E. Corporate R&D
volpecr at crd.ge.com



More information about the Comp.lang.c mailing list