py/mpprint: Fix printing of 64bit integers for 64bit windows builds
This makes all tests pass again for 64bit windows builds which would previously fail for anything printing ranges (builtin_range/unpack1) because they were printed as range( ld, ld ). This is done by reusing the mp_vprintf implementation for MICROPY_OBJ_REPR_D for 64bit windows builds (both msvc and mingw-w64) since the format specifier used for 64bit integers is also %lld, or %llu for the unsigned version. Note these specifiers used to be fetched from inttypes.h, which is the C99 way of working with printf/scanf in a portable way, but mingw-w64 wants to be backwards compatible with older MS C runtimes and uses the non-portable %I64i instead of %lld in inttypes.h, so remove the use of said header again in mpconfig.h and define the specifiers manually.
This commit is contained in:
parent
b61336483b
commit
0a4eb4dbf2
|
@ -909,9 +909,8 @@ typedef double mp_float_t;
|
||||||
#define UINT_FMT "%lu"
|
#define UINT_FMT "%lu"
|
||||||
#define INT_FMT "%ld"
|
#define INT_FMT "%ld"
|
||||||
#elif defined(_WIN64)
|
#elif defined(_WIN64)
|
||||||
#include <inttypes.h>
|
#define UINT_FMT "%llu"
|
||||||
#define UINT_FMT "%"PRIu64
|
#define INT_FMT "%lld"
|
||||||
#define INT_FMT "%"PRId64
|
|
||||||
#else
|
#else
|
||||||
// Archs where mp_int_t == int
|
// Archs where mp_int_t == int
|
||||||
#define UINT_FMT "%u"
|
#define UINT_FMT "%u"
|
||||||
|
|
|
@ -529,7 +529,7 @@ int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args) {
|
||||||
// Because 'l' is eaten above, another 'l' means %ll. We need to support
|
// Because 'l' is eaten above, another 'l' means %ll. We need to support
|
||||||
// this length specifier for OBJ_REPR_D (64-bit NaN boxing).
|
// this length specifier for OBJ_REPR_D (64-bit NaN boxing).
|
||||||
// TODO Either enable this unconditionally, or provide a specific config var.
|
// TODO Either enable this unconditionally, or provide a specific config var.
|
||||||
#if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
|
#if (MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D) || defined(_WIN64)
|
||||||
case 'l': {
|
case 'l': {
|
||||||
unsigned long long int arg_value = va_arg(args, unsigned long long int);
|
unsigned long long int arg_value = va_arg(args, unsigned long long int);
|
||||||
++fmt;
|
++fmt;
|
||||||
|
|
Loading…
Reference in New Issue