1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-02 03:52:49 -05:00

New wrapper macro for printf("%zu"), for old VS compat.

A user reports that Visual Studio 2013 and earlier have printf
implementations in their C library that don't support the 'z' modifier
to indicate that an integer argument is size_t. The 'I' modifier
apparently works in place of it.

To avoid littering ifdefs everywhere, I've invented my own inttypes.h
style macros to wrap size_t formatting directives, which are defined
to %zu and %zx normally, or %Iu and %Ix in old-VS mode. Those are in
defs.h, and they're used everywhere that a %z might otherwise get into
the Windows build.

(cherry picked from commit 82a7e8c4ac)
This commit is contained in:
Simon Tatham
2020-02-09 08:22:56 +00:00
parent cb671ec2d8
commit 8453b9239c
8 changed files with 23 additions and 15 deletions

View File

@ -160,7 +160,7 @@ VOLATILE_WRAPPED_DEFN(, void, log_to_file, (const char *filename))
static const char *outdir = NULL;
char *log_filename(const char *basename, size_t index)
{
return dupprintf("%s/%s.%04zu", outdir, basename, index);
return dupprintf("%s/%s.%04"SIZEu, outdir, basename, index);
}
static char *last_filename;
@ -1574,7 +1574,7 @@ int main(int argc, char **argv)
printf("All tests passed\n");
return 0;
} else {
printf("%zu tests failed\n", nrun - npass);
printf("%"SIZEu" tests failed\n", nrun - npass);
return 1;
}
}