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;
case PT_STRING8:
case PT_UNICODE:
@@ -616,9 +620,9 @@
_PUBLIC_ void mapidump_newmail(struct NewMailNotification *newmail, const char
*sep)
{
- printf("%sParent Entry ID: 0x%llx\n", sep?sep:"", newmail->FID);
+ printf("%sParent Entry ID: 0x%"PRIx64"\n", sep?sep:"", newmail->FID);
fflush(0);
- printf("%sMessage Entry ID: 0x%llx\n", sep?sep:"", newmail->MID);
+ printf("%sMessage Entry ID: 0x%"PRIx64"\n", sep?sep:"", newmail->MID);
fflush(0);
printf("%sMessage flags:\n", sep?sep:"");
fflush(0);
It probably won't work if the C compiler or headers aren't C99 compatible.
As an alternative, we could define them ourselves
#ifndef PRIx64
#if __WORDSIZE == 64
#define PRIx64 "lx"
#else
#define PRIx64 "llx"
#endif
#endif
Thoughts? Comments on relative portability?
Brad
_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel