Interview Questions

My vendor provides header files that define NULL as 0L. Why?

C Interview Questions and Answers


(Continued from previous question...)

My vendor provides header files that define NULL as 0L. Why?

Some programs carelessly attempt to generate null pointers by using the NULL macro, without casts, in non-pointer contexts. (Doing so is not guaranteed to work; ) On machines which have pointers larger than integers (such as PC compatibles in ``large'' model; ), a particular definition of NULL such as 0L can help these incorrect programs to work. (0L is a perfectly valid definition of NULL; it is an ``integral constant expression with value 0.'') Whether it is wise to coddle incorrect programs is debatable.

(Continued on next question...)

Other Interview Questions