This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
h8300, m32c and PRIuPTR
- From: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- To: "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Sun, 15 Mar 2015 17:02:38 -0500
- Subject: h8300, m32c and PRIuPTR
- Authentication-results: sourceware.org; auth=none
Hi
Fighting through more printf() format warnings. This code
compiles without warning on all 18 RTEMS targets with
default arguments but has warnings on a h8300 and m32c
when certain CPU model CFLAGS are added. From a quick
check of the impact of adding the -mcpu=m32cm argument,
it is changing the sizeof(ptr) from 2 to 4 bytes.
==================
#include <stdio.h>
#include <inttypes.h>
void f( uintptr_t x)
{
printf( "%" PRIuPTR "\n", x );
}
==================
The warning is:
f.c:6:3: warning: format '%u' expects argument of type 'unsigned int',
but argument 2 has type 'uintptr_t' [-Wformat=]
printf( "%" PRIuPTR "\n", x );
^
Various compiler options that trigger the warning:
h8300-rtems4.11-gcc -Wall -c f.c <== no warning
h8300-rtems4.11-gcc -mh -mint32 -Wall -c f.c <== warning
h8300-rtems4.11-gcc -msx -Wall -c f.c <== warning
m32c-rtems4.11-gcc -Wall -c f.c <== no warning
m32c-rtems4.11-gcc -mcpu=m32cm -Wall -c f.c <== warning
Any ideas on how to address this?
--joel