fix compile error under Mac OS X

This commit is contained in:
ZHANG Biao 2014-08-14 20:01:01 +08:00
parent 58c49466d2
commit 8dfe2fdd51
2 changed files with 8 additions and 4 deletions

View File

@ -6,6 +6,8 @@
// Must not be included from any .h files to avoid polluting the namespace // Must not be included from any .h files to avoid polluting the namespace
// with macros. // with macros.
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <algorithm> #include <algorithm>
@ -50,13 +52,13 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
break; break;
case kDescriptorFile: case kDescriptorFile:
env->GetFileSize(dbname + "/" + file, &file_size); env->GetFileSize(dbname + "/" + file, &file_size);
Log(options.info_log, "MANIFEST file: %s size: %lu Bytes\n", Log(options.info_log, "MANIFEST file: %s size: %" PRIu64 " Bytes\n",
file.c_str(), file_size); file.c_str(), file_size);
break; break;
case kLogFile: case kLogFile:
env->GetFileSize(dbname + "/" + file, &file_size); env->GetFileSize(dbname + "/" + file, &file_size);
char str[8]; char str[8];
snprintf(str, sizeof(str), "%lu", file_size); snprintf(str, sizeof(str), "%" PRIu64, file_size);
wal_info.append(file).append(" size: "). wal_info.append(file).append(" size: ").
append(str, sizeof(str)).append(" ;"); append(str, sizeof(str)).append(" ;");
break; break;
@ -87,7 +89,7 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
} }
} }
} }
Log(options.info_log, "SST files in %s dir, Total Num: %lu, files: %s\n", Log(options.info_log, "SST files in %s dir, Total Num: %" PRIu64 ", files: %s\n",
db_path.path.c_str(), file_num, file_info.c_str()); db_path.path.c_str(), file_num, file_info.c_str());
file_num = 0; file_num = 0;
file_info.clear(); file_info.clear();
@ -106,7 +108,7 @@ void DumpDBFileSummary(const DBOptions& options, const std::string& dbname) {
if (type == kLogFile) { if (type == kLogFile) {
env->GetFileSize(options.wal_dir + "/" + file, &file_size); env->GetFileSize(options.wal_dir + "/" + file, &file_size);
char str[8]; char str[8];
snprintf(str, sizeof(str), "%lu", file_size); snprintf(str, sizeof(str), "%" PRIu64, file_size);
wal_info.append(file).append(" size: "). wal_info.append(file).append(" size: ").
append(str, sizeof(str)).append(" ;"); append(str, sizeof(str)).append(" ;");
} }

View File

@ -1587,6 +1587,8 @@ class PosixEnv : public Env {
IOPRIO_PRIO_VALUE(3, 0)); IOPRIO_PRIO_VALUE(3, 0));
low_io_priority = true; low_io_priority = true;
} }
#else
(void)decrease_io_priority; // avoid 'unused variable' error
#endif #endif
(*function)(arg); (*function)(arg);
} }