[Development] 0 vs. NULL

René J.V. Bertin rjvbertin at gmail.com
Thu Oct 8 11:27:31 CEST 2015


Hi,

A bit of a generic question, for my personal education. I saw a comment in a code review recently (one related to making Qt build on OS X 10.11, probably) about the preferred use of 0 instead of NULL.

I didn't realise at first why that remark surprised me somewhere. Now I remembered having to modify some of my own code to use NULL instead of 0 to avoid crashing, on 64bit (capable) hardware. I cannot remember the exact details other than that I ended up with undefined (= possibly non zero) bits in the more significant 32 bit word, and that at least some of the functions involved used va_arg. I can also remember slapping my forehead for having been too lazy to type a few extra characters...

Is it certain that there are no pitfalls that come with trusting the compiler to do the proper conversions, on all platforms where Qt is supposed to work? Did I simply hit a "feature" Qt won't ever encounter because it doesn't use C (nor va_arg)?

R.



More information about the Development mailing list