Add portable way of formatting khint_t type (from klib)

This commit is contained in:
Iestyn Pryce
2017-05-21 11:58:37 +01:00
parent d8239a9cc4
commit 87cf7b5bca
2 changed files with 6 additions and 2 deletions

View File

@@ -662,7 +662,7 @@ address_parser_t *address_parser_init(char *filename) {
}
log_info("Done with vocab, total size=%zu\n", kh_size(vocab));
log_info("Done with vocab, total size=%" PRIkh32 "\n", kh_size(vocab));
for (k = kh_begin(vocab); k != kh_end(vocab); ++k) {
token = (char *)kh_key(vocab, k);
@@ -676,7 +676,7 @@ address_parser_t *address_parser_init(char *filename) {
}
}
log_info("After pruning vocab size=%zu\n", kh_size(vocab));
log_info("After pruning vocab size=%" PRIkh32 "\n", kh_size(vocab));
log_info("Creating phrases trie\n");

View File

@@ -101,14 +101,18 @@ int main() {
#if UINT_MAX == 0xffffffffu
typedef unsigned int khint32_t;
#define PRIkh32 "u"
#elif ULONG_MAX == 0xffffffffu
typedef unsigned long khint32_t;
#define PRIkh32 "lu"
#endif
#if ULONG_MAX == ULLONG_MAX
typedef unsigned long khint64_t;
#define PRIkh64 "lu"
#else
typedef unsigned long long khint64_t;
#define PRIkh64 "llu"
#endif
#ifndef kh_inline