More NULL questions

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Oct 7 05:02:30 AEST 1989


In article <5950001 at hpldola.HP.COM> jg at hpldola.HP.COM (Joe Gilray) writes:
>1) what is the danger with using
>         if (ptr != NULL) ...
>   as apposed to
>         if (ptr != (struct thing *)NULL) ...

There is no danger, assuming the C implementation is correct.

>2) Is there danger using
>         my_func(a, NULL, b);
>   as apposed to
>         my_func(a, (struct thing *)NULL, b);
>   when
>   a) you are using function prototypes?

The only danger is that someone may port your code to a "classic C"
environment and miss making the necessary edit.

>   b) you are NOT using function prototypes (like me)?

Yes, it is erroneous to feed NULL to a function where a pointer argument
is expected.



More information about the Comp.lang.c mailing list