[Mesa-dev] [PATCH] gen_matypes: eliminate printf warnings
Jose Fonseca
jfonseca at vmware.com
Fri Dec 9 07:13:35 PST 2011
----- Original Message -----
> On 12/09/2011 07:59 AM, Jose Fonseca wrote:
> >
> >
> > ----- Original Message -----
> >> On 12/09/2011 07:00 AM, nobled wrote:
> >>> The VERT_BIT_* defines are 64-bit values since commit
> >>> f364ac1da10ff67eba5196c1074aff579864f741, but the printf
> >>> was still expecting a simple int. This worked on little-endian
> >>> hosts because the values were still less than INT_MAX, but
> >>> probably would've gone bad and printed zero on big-endian ones.
> >>> ---
> >>> src/mesa/x86/gen_matypes.c | 7 ++++++-
> >>> 1 files changed, 6 insertions(+), 1 deletions(-)
> >>>
> >>> diff --git a/src/mesa/x86/gen_matypes.c
> >>> b/src/mesa/x86/gen_matypes.c
> >>> index 648bf87..18baa29 100644
> >>> --- a/src/mesa/x86/gen_matypes.c
> >>> +++ b/src/mesa/x86/gen_matypes.c
> >>> @@ -32,6 +32,11 @@
> >>> * Mesa, including lighting, clipping, texture image
> >>> conversion
> >>> etc.
> >>> */
> >>>
> >>> +#ifndef __STDC_FORMAT_MACROS
> >>> +#define __STDC_FORMAT_MACROS
> >>> +#endif
> >>> +#include<inttypes.h>
> >>> +
> >>> #include "main/glheader.h"
> >>> #include "main/mtypes.h"
> >>> #include "tnl/t_context.h"
> >>> @@ -68,7 +73,7 @@ do { \
> >>> printf( "#define %s\t%lu\n", s, (unsigned long) sizeof(t)
> >>> );
> >>>
> >>> #define DEFINE( s, d ) \
> >>> - printf( "#define %s\t0x%x\n", s, d );
> >>> + printf( "#define %s\t0x%"PRIx64"\n", s, (uint64_t) d );
> >>
> >>
> >> I'm not sure that inttypes.h exists on Windows. We may need some
> >> #ifdef stuff there.
> >
> > We provide our own in mesa/include/c99/ so it should be ok.
>
> Oh that's right.
>
> BTW, there's a few other places where we want to print 64-bit values
> and use the %llx format plus (unsigned long long) casting. But that
> generates warnings on some platforms. I think we could fix those if
> we used the "PRI" macros in those places.
Sounds good. I think the mesa/include/c99/inttypes.h is fairly comprehensive. If not we could just add any missing bits.
Jose
More information about the mesa-dev
mailing list