Skip to content

Commit

Permalink
Fix C compilation warning
Browse files Browse the repository at this point in the history
gcc 8.3.0 emits this during python setup.py build:

persistent/cPersistence.c: In function ‘Per_repr’:
persistent/cPersistence.c:1481:44: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
         snprintf(buf, sizeof(buf) - 1, "%llx", oid_value);
                                         ~~~^   ~~~~~~~~~
                                         %lx

<stdint.h> defines standard macros such as PRId64, PRIu64 and PRIx64 for
printing {u,}int64_t values, so let's use them.
  • Loading branch information
mgedmin committed Apr 25, 2019
1 parent d64c976 commit dc261e6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion persistent/cPersistence.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct ccobject_head_struct
*/
#if !defined(PY3K) && defined(_WIN32)
typedef unsigned long long uint64_t;
#define PRIx64 "llx"
#else
#include <stdint.h>
#endif
Expand Down Expand Up @@ -1478,7 +1479,7 @@ Per_repr(cPersistentObject *self)
length modifier for %x, so to format a 64-bit value we need to
use stdio.
*/
snprintf(buf, sizeof(buf) - 1, "%llx", oid_value);
snprintf(buf, sizeof(buf) - 1, "%" PRIx64, oid_value);
oid_str = PyUnicode_FromFormat(" oid 0x%s", buf);
}

Expand Down

0 comments on commit dc261e6

Please sign in to comment.