This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

printf/inttypes.h warning


I haven't investigated which other targets have this inconsistency yet.
But the following code gives a printf format warning on i386-rtems but not
on sparc-rtems.

#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>

void f(uintptr_t me)
  printf( "A: %" PRIdPTR " B: %" PRIdPTR "\n", me, 1 - me );

This is because intptr_t and uintptr_t are defined as just unsigned int
on sparc but long unsigned int on i386. 

$ sparc-rtems4.11-gcc -dM -E - </dev/null | grep INTPTR
#define __INTPTR_MAX__ 2147483647
#define __INTPTR_TYPE__ int
#define __UINTPTR_MAX__ 4294967295U
#define __UINTPTR_TYPE__ unsigned int
$ i386-rtems4.11-gcc -dM -E - </dev/null | grep INTPTR
#define __INTPTR_MAX__ 2147483647L
#define __INTPTR_TYPE__ long int
#define __UINTPTR_MAX__ 4294967295UL
#define __UINTPTR_TYPE__ long unsigned int

I don't know whether to start sweeping through gcc and try to get
these all to just unsigned int or add target architecture specific logic
to fine tune the inttypes.h that newlib has. It looks like the
logic I added a few months cleared up a lot of these but not all.

Suggestions welcomed.


Joel Sherrill, Ph.D.             Director of Research & Development        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]