language agnostic - Any reason to use hex notation for null pointers? -
I am currently improving one part of our COM component which logs all the external calls in one file for points We write (IInterface *) 0x12345678
with the value of the actual code.
There is currently no difference for zero pointers - they do not have any problem changing the behavior of 0x0
which is the iMO sub-symmetrical and incompatible. But first I want to know - is there any real advantage in representing the Null Pointer in Hex?
Personally, I could print 0x0
in the log file [*] For some days when a person comes to parse the file automatically, then more equality is better than data. I do not find the 0x0
to read, so this is a special case in the author code, and there is a special case in the reader code, which I can think of without being silly. For Grepping the log for NULLs / P>
0x0
is also better for 0
: You have to find out that you're grepping for Should be 0
or something strange.
I will not write 0x0
for a pointless pointers constant in C or C ++, though. I write non-null addresses so incredibly that there is nothing equal to the tap. I think if I was defining a bunch of constants to represent the memory map of some devices, then and that zero address was important in that memory map, then I would call it 0x0 I can write in that context.
[*] Or maybe
0x00000000
. I like to print 32-bit pointers for 8 characters long, because when I read / I read an indicator I start from the left in pairs. If it exits for 7 characters, then I'm very confused at the end ;-) 64-bit pointers it does not matter, because I do not remember how long ...
Comments
Post a Comment