This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
warning: '0' flag used with '%p' printf format
- From: John Breitenbach <breiten at lexmark dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 21 May 2009 17:23:59 -0400
- Subject: warning: '0' flag used with '%p' printf format
Hi,
Upon upgrading to gcc-4.2.0, I have begun to get warnings about using
"0x%08x" when formatting
pointer arguments for printf-type functions. I obviously should change
the %x to %p. But when I do
this, I haven't been able to find a way to continue to have my leading
zeros.
gcc warns about asking for leading zeros with %p as in %010p, and
eliminating warnings is why this subject came
up at all. However, %010p (leading zeros, 10 chars wide), DOES give me
the desired output on my RedHat-EL4
workstation.
My questions are 1) is this an appropriate warning? and 2) how
could/should I get my desired behavior (0x followed
by exactly 8 digits) and still use %p to specify pointers?
PS - all of my data pointers will need all 8 hex digits and thus won't
have/need leading zeros. But code pointers won't,
and I'd like things to line up.
Thanks, John