From 82ca10acb643f0471c0f35687d1bfefd5d23deae Mon Sep 17 00:00:00 2001 From: tqchen Date: Sat, 25 Apr 2015 20:52:07 -0700 Subject: [PATCH] better handling at msvc --- include/dmlc/io.h | 12 ++++++------ include/rabit/utils.h | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/dmlc/io.h b/include/dmlc/io.h index f808094c1..1b7d70498 100644 --- a/include/dmlc/io.h +++ b/include/dmlc/io.h @@ -300,7 +300,7 @@ class istream : public std::basic_istream { // implementations of inline functions template inline void Stream::Write(const std::vector &vec) { - size_t sz = vec.size(); + uint64_t sz = static_cast(vec.size()); this->Write(&sz, sizeof(sz)); if (sz != 0) { this->Write(&vec[0], sizeof(T) * sz); @@ -308,25 +308,25 @@ inline void Stream::Write(const std::vector &vec) { } template inline bool Stream::Read(std::vector *out_vec) { - size_t sz; + uint64_t sz; if (this->Read(&sz, sizeof(sz)) == 0) return false; - out_vec->resize(sz); + out_vec->resize(static_cast(sz)); if (sz != 0) { if (this->Read(&(*out_vec)[0], sizeof(T) * sz) == 0) return false; } return true; } inline void Stream::Write(const std::string &str) { - size_t sz = str.length(); + uint64_t sz = static_cast(str.length()); this->Write(&sz, sizeof(sz)); if (sz != 0) { this->Write(&str[0], sizeof(char) * sz); } } inline bool Stream::Read(std::string *out_str) { - size_t sz; + uint64_t sz; if (this->Read(&sz, sizeof(sz)) == 0) return false; - out_str->resize(sz); + out_str->resize(static_cast(sz)); if (sz != 0) { if (this->Read(&(*out_str)[0], sizeof(char) * sz) == 0) { return false; diff --git a/include/rabit/utils.h b/include/rabit/utils.h index aae3c6ab4..0f48fa0fa 100644 --- a/include/rabit/utils.h +++ b/include/rabit/utils.h @@ -43,10 +43,10 @@ extern "C" { #ifdef _MSC_VER typedef unsigned char uint8_t; -typedef unsigned short int uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long uint64_t; -typedef long int64_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +typedef __int64 int64_t; #else #include #endif