Browse Source

Don't use PRIx64 formatting derives from inttypes.h

As the tinyformat-based formatting system (introduced in b77dfdc) is
type-safe, no special format characters are needed to specify sizes.

Tinyformat can support (ignore) the C99 prefixes such as "ll" but
chokes on MSVC's inttypes.h defines prefixes such as "I64X". So don't
include inttypes.h and define our own for compatibility.

(an alternative would be to sweep the entire codebase using sed -i to
get rid of the size specifiers but this has less diff impact)
0.10
Wladimir J. van der Laan 11 years ago
parent
commit
d5f1e727a8
  1. 1
      src/alert.cpp
  2. 1
      src/db.cpp
  3. 1
      src/init.cpp
  4. 1
      src/main.cpp
  5. 1
      src/net.h
  6. 2
      src/rpcnet.cpp
  7. 27
      src/util.h
  8. 2
      src/wallet.cpp
  9. 2
      src/walletdb.cpp

1
src/alert.cpp

@ -11,7 +11,6 @@
#include "util.h" #include "util.h"
#include <algorithm> #include <algorithm>
#include <inttypes.h>
#include <map> #include <map>
#include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/classification.hpp>

1
src/db.cpp

@ -10,7 +10,6 @@
#include "protocol.h" #include "protocol.h"
#include "util.h" #include "util.h"
#include <inttypes.h>
#include <stdint.h> #include <stdint.h>
#ifndef WIN32 #ifndef WIN32

1
src/init.cpp

@ -24,7 +24,6 @@
#include "walletdb.h" #include "walletdb.h"
#endif #endif
#include <inttypes.h>
#include <stdint.h> #include <stdint.h>
#ifndef WIN32 #ifndef WIN32

1
src/main.cpp

@ -17,7 +17,6 @@
#include "ui_interface.h" #include "ui_interface.h"
#include "util.h" #include "util.h"
#include <inttypes.h>
#include <sstream> #include <sstream>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>

1
src/net.h

@ -18,7 +18,6 @@
#include "util.h" #include "util.h"
#include <deque> #include <deque>
#include <inttypes.h>
#include <stdint.h> #include <stdint.h>
#ifndef WIN32 #ifndef WIN32

2
src/rpcnet.cpp

@ -15,8 +15,6 @@
#include "wallet.h" // for getinfo #include "wallet.h" // for getinfo
#endif #endif
#include <inttypes.h>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include "json/json_spirit_value.h" #include "json/json_spirit_value.h"

27
src/util.h

@ -16,7 +16,6 @@
#include <cstdio> #include <cstdio>
#include <exception> #include <exception>
#include <inttypes.h>
#include <map> #include <map>
#include <stdarg.h> #include <stdarg.h>
#include <stdint.h> #include <stdint.h>
@ -45,13 +44,25 @@ static const int64_t CENT = 1000000;
#define UEND(a) ((unsigned char*)&((&(a))[1])) #define UEND(a) ((unsigned char*)&((&(a))[1]))
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0])) #define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
/* Format characters for (s)size_t and ptrdiff_t (C99 standard) */ /* Format characters for (s)size_t, ptrdiff_t, uint64_t.
#define PRIszx "zx" *
#define PRIszu "zu" * As the tinyformat-based formatting system is type-safe, no special format
#define PRIszd "zd" * characters are really needed to specify sizes. Tinyformat can support
#define PRIpdx "tx" * (ignores) the C99 prefixes such as "ll" but chokes on MSVC's inttypes
#define PRIpdu "tu" * defines prefixes such as "I64X". So don't include inttypes.h and define our
#define PRIpdd "td" * own for compatibility.
* If you get a warning here about a redefine of PRI?64, make sure that
* inttypes.h is not included.
*/
#define PRIszx "x"
#define PRIszu "u"
#define PRIszd "d"
#define PRIpdx "x"
#define PRIpdu "u"
#define PRIpdd "d"
#define PRIx64 "x"
#define PRIu64 "u"
#define PRId64 "d"
// This is needed because the foreach macro can't get over the comma in pair<t1, t2> // This is needed because the foreach macro can't get over the comma in pair<t1, t2>
#define PAIRTYPE(t1, t2) std::pair<t1, t2> #define PAIRTYPE(t1, t2) std::pair<t1, t2>

2
src/wallet.cpp

@ -9,8 +9,6 @@
#include "coincontrol.h" #include "coincontrol.h"
#include "net.h" #include "net.h"
#include <inttypes.h>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <openssl/rand.h> #include <openssl/rand.h>

2
src/walletdb.cpp

@ -11,8 +11,6 @@
#include "sync.h" #include "sync.h"
#include "wallet.h" #include "wallet.h"
#include <inttypes.h>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>

Loading…
Cancel
Save