Skip to content

Commit 4287fa2

Browse files
committed
SIMH: Fix sim_printf_fmts.h for Visual Stduio 2013 and older
Updated with bscottm's suggested fixes to keep ANSI syntax for VS 2015 and later.
1 parent 01c4333 commit 4287fa2

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

sim_printf_fmts.h

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,26 @@
3232
* POINTER_FMT: Format modifier for pointers, e.g. "%08" POINTER_FMT "X"
3333
*/
3434

35-
#if defined (_WIN32) || defined(_WIN64)
36-
37-
/* 64-bit Visual Studio or MINGW build */
38-
# if defined(_WIN64) || defined(__MINGW64__)
39-
# define LL_FMT "I64"
40-
# define SIZE_T_FMT "I64"
41-
/* 32-bit Visual Studio or MINGW build */
42-
# elif defined(_WIN32) || defined(__MINGW32__)
43-
# define LL_FMT "ll"
44-
# define SIZE_T_FMT "I32"
45-
# else
46-
/* Graceful fail -- shouldn't ever default to this on a Windows platform. */
47-
# define LL_FMT "ll"
48-
# define SIZE_T_FMT "I32"
35+
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
36+
# if _MSC_VER >= 1900 || defined(__USE_MINGW_ANSI_STDIO)
37+
/* VS 2015 or later, MinGW with ANSI stdio: Use the standard. Don't assume that
38+
* MS or MinGW will support the "I" qualifier indefinitely. */
39+
# define SIZE_T_FMT "z"
40+
# define T_UINT64_FMT "j"
41+
# define T_INT64_FMT "j"
42+
# elif (_MSC_VER < 1900 && defined(_WIN64)) || defined(__MINGW64__)
43+
/* VS 2013 and earlier, 64-bit: use Microsoft's "I" qualifier. */
44+
# define SIZE_T_FMT "I64"
45+
# define T_UINT64_FMT "I64"
46+
# define T_INT64_FMT "I64"
47+
# elif (_MSC_VER < 1900 && defined(_WIN32)) || defined(__MINGW32__)
48+
/* VS 2013 and earlier, 32-bit: use Microsoft's "I" qualifier. */
49+
# define SIZE_T_FMT "I32"
50+
# define T_UINT64_FMT "I64"
51+
# define T_INT64_FMT "I64"
4952
# endif
5053

51-
# define T_UINT64_FMT "I64"
52-
# define T_INT64_FMT "I64"
54+
# define LL_FMT "ll"
5355
# define POINTER_FMT "p"
5456

5557
#elif defined(__GNU_LIBRARY__) || defined(__GLIBC__) || defined(__GLIBC_MINOR__) || \

0 commit comments

Comments
 (0)