]> git.notmuchmail.org Git - notmuch/commitdiff
Fix printf for when uint64_t != unsigned long long int
authorCarl Worth <cworth@cworth.org>
Tue, 9 Feb 2010 19:09:30 +0000 (11:09 -0800)
committerCarl Worth <cworth@cworth.org>
Tue, 9 Feb 2010 19:14:16 +0000 (11:14 -0800)
Thanks to Michal Sojka <sojkam1@fel.cvut.cz> for pointing out the
correct fix, which I verified in the freely-available WG14/N1124 draft
(from the C99 working group) which is available here:

http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1124.pdf

lib/database-private.h
lib/database.cc

index 5bb6e86c735fd80d53efcc801f4a4697cba5bd31..41918d760fe82bed3c960f07f08f30159d3e4231 100644 (file)
 #ifndef NOTMUCH_DATABASE_PRIVATE_H
 #define NOTMUCH_DATABASE_PRIVATE_H
 
+/* According to WG14/N1124, a C++ implementation won't provide us a
+ * macro like PRIx64 (which gives a printf format string for
+ * formatting a uint64_t as hexadecimal) unless we define
+ * __STDC_FORMAT_MACROS before including inttypes.h. That's annoying,
+ * but there it is.
+ */
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+
 #include "notmuch-private.h"
 
 #include <xapian.h>
index 8641321511bd12c85eac6e1c91fe9c486d92e4c5..2b5b64dffd9bf0499a0ca70534eba115366610b3 100644 (file)
@@ -1306,7 +1306,7 @@ _notmuch_database_generate_thread_id (notmuch_database_t *notmuch)
 
     notmuch->last_thread_id++;
 
-    sprintf (thread_id, "%016llx", notmuch->last_thread_id);
+    sprintf (thread_id, "%016" PRIx64, notmuch->last_thread_id);
 
     db->set_metadata ("last_thread_id", thread_id);