i am getting the following warning when i compile in C.
../tcpuip/uip_arp.c: In function 'display_arp_table':
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_p
rintf format
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_p
rintf format
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_p
rintf format
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_p
rintf format
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_p
rintf format
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_p
rintf format
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_p
rintf format
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_p
rintf format
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_p
rintf format
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_p
rintf format
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_p
rintf format
../tcpuip/uip_arp.c:547: warning: '0' flag ignored with precision and '%x' gnu_printf format
the line where the error comes is
RELEASE_MSG("MAC: %0.2x.%0.2x.%0.2x.%0.2x.%0.2x.%0.2x ",(unsigned char)tabptr->ethaddr.addr[0],(unsigned char)tabptr->ethaddr.addr[1],(unsigned char)tabptr->ethaddr.addr[2],(unsigned char)tabptr->ethaddr.addr[3],(unsigned char)tabptr->ethaddr.addr[4],(unsigned char)tabptr->ethaddr.addr[5]);
tabptr is a pointer of struct arp_entry
PACKED struct arp_entry {
u16_t ipaddr[2];
struct uip_eth_addr ethaddr;
u8_t time;
#ifdef _ALIGNED_
u8_t dummy;
#endif
}
and ethadder is a pointer for struct uip_eth_addr
PACKED struct uip_eth_addr {
u8_t addr[6];
} ;
Please if anyone can share some light on this warning. I just know that %0.2x means character as two digit HEX. Help!
The format string
%0.2xmeans:Since the precision defines the minimum number of digits to output, the zero padding will be ignored (from the specification). You can use
%.2xor%02xthat will do what you want.To get
You’d use
%4x.would be
%4.2xwould be
%04xor%.4x.Note that there is difference when the value is signed. The precision defines the number of digits, meaning the value will occupy one more space for the sign. With minimum output width, sign is already counted: