|
5 | 5 | * this header so that these formats are available to more than SCP. |
6 | 6 | * |
7 | 7 | * Author: B. Scott Michel |
| 8 | + * C. Gauger-Cosgrove |
8 | 9 | * |
9 | 10 | * "scooter me fecit" |
10 | 11 | *~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~*/ |
|
15 | 16 | /* cross-platform printf() format specifiers: |
16 | 17 | * |
17 | 18 | * 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. |
19 | 22 | * |
20 | 23 | * MinGW note: __MINGW64__ and __MINGW32__ are both defined by 64-bit gcc. Check |
21 | 24 | * for __MINGW64__ before __MINGW32__. |
|
29 | 32 | * POINTER_FMT: Format modifier for pointers, e.g. "%08" POINTER_FMT "X" |
30 | 33 | */ |
31 | 34 |
|
32 | | -#if defined (_WIN32) || defined(_WIN64) |
33 | | - |
34 | | -# if defined(__MINGW64__) |
35 | | -# define LL_FMT "I64" |
36 | | -# define SIZE_T_FMT "I64" |
37 | | -# elif defined(_MSC_VER) || defined(__MINGW32__) |
38 | | -# define LL_FMT "ll" |
39 | | -# define SIZE_T_FMT "z" |
40 | | -# else |
41 | | - /* Graceful fail -- shouldn't ever default to this on a Windows platform. */ |
42 | | -# define LL_FMT "ll" |
43 | | -# 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" |
44 | 52 | # endif |
45 | 53 |
|
46 | | -# define T_UINT64_FMT "I64" |
47 | | -# define T_INT64_FMT "I64" |
| 54 | +# define LL_FMT "ll" |
48 | 55 | # define POINTER_FMT "p" |
49 | 56 |
|
50 | 57 | #elif defined(__GNU_LIBRARY__) || defined(__GLIBC__) || defined(__GLIBC_MINOR__) || \ |
|
0 commit comments