In C, I'd like to use printf to display pointers, and so that they line up properly, I'd like to pad them with 0s.
My guess was that the proper way to do this was:
printf("%016p", ptr);
This works, but this gcc complains with the following message:
warning: '0' flag used with ‘%p’ gnu_printf format
I've googled a bit for it, and the following thread is on the same topic, but doesn't really give a solution.
http://gcc.gnu.org/ml/gcc-bugs/2003-05/msg00484.html
Reading it, it seems that the reason why gcc complains is that the syntax I suggested is not defined in C99. But I can't seem to find any other way to do the same thing in a standard approved way.
So here is the double question:
#include <inttypes.h>
#include <stdint.h>
printf("%016" PRIxPTR "\n", (uintptr_t)ptr);
but it won't print the pointer in the implementation defined way (says DEAD:BEEF
for 8086 segmented mode).