As an aside, that looks generally wrong:

printf("%llx", (*(const long long unsinged *)data));

Surely:

printf("%llx", ((const long long unsinged)(*data)));

Otherwise you may get a load of rubbish adjacent to *data, unless you "know" 
that the full storage has been allocated.

Sam 

-----Original Message-----
From: Stefan (metze) Metzmacher <[EMAIL PROTECTED]>
Sent: 07 September 2008 14:40
To: Brad Hards <[EMAIL PROTECTED]>
Cc: devel@openchange.org
Subject: Re: [openchange][devel] Using <inttypes.h> macros

Brad Hards schrieb:
> I do a fair amount of my development work on an AMD64 box.
> 
> During compilation, I see a lot of warnings of the form:
> format ‘%llx’ expects type ‘long long unsigned int’, but argument 3 has type 
> ‘uint64_t’
> 
> gcc thinks that it should be "%lx" if the wordsize is 64 bits.
> 
> There is a way to fix this - using the PRIx64 (for example) macro from 
> <inttypes.h>.
> 
> Here is an example of what it will look like:
> --- libmapi/mapidump.c  (revision 716)
> +++ libmapi/mapidump.c  (working copy)
> @@ -21,6 +21,10 @@
>  #include <libmapi/mapidump.h>
>  #include <libmapi/proto_private.h>
> 
> +#ifndef __STDC_FORMAT_MACROS
> +#define __STDC_FORMAT_MACROS 1
> +#endif
> +#include <inttypes.h>
>  /**
>     \file mapidump.c
> 
> @@ -49,7 +53,7 @@
>                 break;
>         case PT_I8:
>                 data = get_SPropValue_data(&lpProp);
> -               printf("%s%s: %llx\n", sep?sep:"", proptag, (*(const uint64_t 
> *)data));
> +               printf("%s%s: %"PRIx64"\n", sep?sep:"", proptag, (*(const 
> uint64_t *)data));
>                 break;

In samba we would just use:
printf("%llx", (*(const long long unsinged *)data));

metze


_______________________________________________
devel mailing list
devel@openchange.org
http://mailman.openchange.org/listinfo/devel

Reply via email to