gcc did not add nullptr until gcc 4.6. For gcc <= 4.5 (like Android's
gcc 4.4), we should consider using gcc's magic __null:
#define nullptr __null
Also, gcc 4.7 added a new -Wzero-as-null-pointer-constant warning to
flag uses of literal 0 as a pointer (in C++ code). We could enable this
warning as a helpful reminder to use nullptr.
chris p.
On 7/25/12 2:45 AM, Aryeh Gregor wrote:
The C++11 standard defines a new dedicated null-pointer symbol, "nullptr". It provides better type-safety than
existing null-pointer definitions, because it doesn't allow implicit conversion to numeric types. In
<https://bugzilla.mozilla.org/show_bug.cgi?id=626472> I defined "nullptr" to mean 0L/0LL (like current
nsnull) where unsupported, then redefined "nsnull" to mean "nullptr". This caught a bunch of places
where people were using nsnull to mean crazy things like NS_OK or other things that happened to equal 0.
The next step is to s/nsnull/nullptr/ in the codebase, and get rid of nsnull. There's no reason
for us to use our own identifier when there's a standard one. This will be of comparable scale to
the PRBool elimination of last year -- around 20,000 lines changed instead of 30,000. This will of
course insta-bitrot any patches that people have that mention "nsnull" anywhere, but a
shell script will be provided to auto-fix them, as with the PRBool switch (something like "sed
-i s/\bnsnull\b/nullptr/ .hg/patches{,-*}/*" should do it).
This message is of general interest because after the switch, "nsnull" will no
longer work, and patch queues will have to be updated. Also, anyone who maintains a
branch will want to figure out how to avoid merge pain.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform