Skip to content

Commit f2252fd

Browse files
committed
Introduce standard macros for format specifiers
There exist standard macro definitions for the printf format specifiers. MS Visual Studio does not support that standard (at least not in older versions), so local definitions are needed there. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 2008daf commit f2252fd

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

ccutil/host.h

+18-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
#undef max
6969
#endif
7070

71-
#include <stdint.h> // int32_t, ...
71+
#include <inttypes.h> // PRId32, ...
72+
#include <stdint.h> // int32_t, ...
7273

7374
/********************************************************/
7475
/* __MAC__ */
@@ -111,8 +112,22 @@ typedef float FLOAT32;
111112
typedef double FLOAT64;
112113
typedef unsigned char BOOL8;
113114

114-
#define INT32FORMAT "%d"
115-
#define INT64FORMAT "%lld"
115+
#if defined(_WIN32)
116+
117+
/* MinGW defines the standard PRI... macros, but MSVS doesn't. */
118+
119+
#if !defined(PRId32)
120+
# define PRId32 "d"
121+
#endif
122+
123+
#if !defined(PRId64)
124+
# define PRId64 "I64d"
125+
#endif
126+
127+
#endif /* _WIN32 */
128+
129+
#define INT32FORMAT "%" PRId32
130+
#define INT64FORMAT "%" PRId64
116131

117132
#define MAX_INT8 0x7f
118133
#define MAX_INT16 0x7fff

0 commit comments

Comments
 (0)