Closed GoogleCodeExporter closed 9 years ago
Cross platform code should use either system function to print address or use
ptrdiff_t (from malloc.h) or similar type.
Working test:
#include <unistd.h>
#include <malloc.h>
static void wra(int fd, const void *addr)
{
const unsigned int ptrbitsshift = (sizeof(ptrdiff_t) << 3) - 4;
char digits[] = "0123456789ABCDEF";
write(fd, "0x", 2);
for (int shift=ptrbitsshift; shift>=0; shift-=4)
write(fd, &digits[(((ptrdiff_t)addr)>>shift)&0xF], 1);
}
int main(int argc, char** argv) {
int c = '\n';
wra(1, &c);
write(1, &c, 1);
}
Original comment by sstas...@gmail.com
on 9 Mar 2007 at 10:34
Seems reasonable to me. Care to attach a full patch which makes wvstreams
compile on
your system? I'd be more than happy to apply it.
Original comment by wrl...@gmail.com
on 16 Mar 2007 at 7:08
Ah, I see, wra is basically a replacement for a function in wvcrash.cc. Looks
reasonable, let's commit.
Original comment by wrl...@gmail.com
on 2 Jul 2007 at 8:28
Original issue reported on code.google.com by
sstas...@gmail.com
on 9 Mar 2007 at 9:50