Skip to content

Commit

Permalink
Introduce standard macros for format specifiers
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
stweil committed May 11, 2017
1 parent 2008daf commit f2252fd
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions ccutil/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
#undef max
#endif

#include <stdint.h> // int32_t, ...
#include <inttypes.h> // PRId32, ...
#include <stdint.h> // int32_t, ...

/********************************************************/
/* __MAC__ */
Expand Down Expand Up @@ -111,8 +112,22 @@ typedef float FLOAT32;
typedef double FLOAT64;
typedef unsigned char BOOL8;

#define INT32FORMAT "%d"
#define INT64FORMAT "%lld"
#if defined(_WIN32)

/* MinGW defines the standard PRI... macros, but MSVS doesn't. */

#if !defined(PRId32)
# define PRId32 "d"
#endif

#if !defined(PRId64)
# define PRId64 "I64d"
#endif

#endif /* _WIN32 */

#define INT32FORMAT "%" PRId32
#define INT64FORMAT "%" PRId64

#define MAX_INT8 0x7f
#define MAX_INT16 0x7fff
Expand Down

0 comments on commit f2252fd

Please sign in to comment.