On Fri, Apr 25, 2008 at 06:16:40PM +0200, Justus Winter wrote:
diff -pru dw2/lout/object.cc dw2-cur/lout/object.cc --- dw2/lout/object.cc 2007-10-26 14:17:43.000000000 +0200 +++ dw2-cur/lout/object.cc 2008-04-25 17:20:56.000000000 +0200 @@ -22,6 +22,7 @@
#include "object.hh" #include <stdio.h> +#include <unistd.h> // for intptr_t
inttypes.h
void Pointer::intoStringBuffer(misc::StringBuffer *sb) { char buf[64]; - if(sizeof (int) == sizeof (void*)) - sprintf(buf, "0x%x", (int)value); - else if (sizeof (long) == sizeof (void*)) - sprintf(buf, "0x%lx", (long)value); - else { - // unhandled case - misc::assertNotReached (); - } + sprintf(buf, "0x%lx", (intptr_t)value);
snprintf(buf, sizeof(buf), "%p", value) if you don't care about the concrete representation, typically this is using hex as well. If you really do: snprintf(buf, sizeof(buf), "0x%zu", (size_t)value); Joerg