Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!crdgw1!camelback!volpe From: volpe@camelback.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: Is there a NULL pointer to functions? Message-ID: <19996@crdgw1.crd.ge.com> Date: 29 May 91 04:16:32 GMT References: <1991May21.125639.10052@umiami.ir.miami.edu> <4416@inews.intel.com> <748@taumet.com> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@camelback.crd.ge.com (Christopher R Volpe) Distribution: na Lines: 31 In article <748@taumet.com>, steve@taumet.com (Stephen Clamage) writes: |>bhoughto@pima.intel.com (Blair P. Houghton) writes: |> |>>In article <1991May21.125639.10052@umiami.ir.miami.edu> devebw9f@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@crd.ge.com