Skip to content

Commit 01c4333

Browse files
committed
SIMH: Fix sim_printf_fmts.h for Visual Stduio 2013 and older
Per Microsoft documentation versions Visual Studio 2013 and below do not support the hh, j, z, and t length prefixes for printf format-type specifiers. Further, the preprocessor selection logic was modified so that 64-bit Visual Studio versions are actually recognized.
1 parent c5d1f8c commit 01c4333

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

sim_printf_fmts.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* this header so that these formats are available to more than SCP.
66
*
77
* Author: B. Scott Michel
8+
* C. Gauger-Cosgrove
89
*
910
* "scooter me fecit"
1011
*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~*/
@@ -15,7 +16,9 @@
1516
/* cross-platform printf() format specifiers:
1617
*
1718
* Note: MS apparently does recognize "ll" as "l" in its printf() routines, but "I64" is
18-
* preferred for 64-bit types.
19+
* preferred for 64-bit types. _MSC_VER and _WIN32 are always defined for Visual Studio
20+
* builds. To check if the build is using 64-bit Visual Studio, you must check if the
21+
* _WIN64 macro is defined.
1922
*
2023
* MinGW note: __MINGW64__ and __MINGW32__ are both defined by 64-bit gcc. Check
2124
* for __MINGW64__ before __MINGW32__.
@@ -31,12 +34,14 @@
3134

3235
#if defined (_WIN32) || defined(_WIN64)
3336

34-
# if defined(__MINGW64__)
37+
/* 64-bit Visual Studio or MINGW build */
38+
# if defined(_WIN64) || defined(__MINGW64__)
3539
# define LL_FMT "I64"
3640
# define SIZE_T_FMT "I64"
37-
# elif defined(_MSC_VER) || defined(__MINGW32__)
41+
/* 32-bit Visual Studio or MINGW build */
42+
# elif defined(_WIN32) || defined(__MINGW32__)
3843
# define LL_FMT "ll"
39-
# define SIZE_T_FMT "z"
44+
# define SIZE_T_FMT "I32"
4045
# else
4146
/* Graceful fail -- shouldn't ever default to this on a Windows platform. */
4247
# define LL_FMT "ll"

0 commit comments

Comments
 (0)