Fixed some warnings on VisualStudio2010

This commit is contained in:
Mathieu Labbé
2015-04-01 10:38:59 -04:00
parent 6089a44589
commit 37c34e8186
10 changed files with 27 additions and 23 deletions

View File

@@ -23,7 +23,7 @@ INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
ADD_LIBRARY(rtabmap_utilite ${SRC_FILES})
IF(MINGW)
TARGET_LINK_LIBRARIES(rtabmap_utilite ${PTHREADS_LIBRARY} "-lpsapi")
ELSEIF(WIN32)
ELSEIF(WIN32 OR MSVC)
FIND_LIBRARY(PSAPI_LIBRARIES NAMES psapi libpsapi.dll.a libpsapi.a libpsapi.lib )
TARGET_LINK_LIBRARIES(rtabmap_utilite ${PSAPI_LIBRARIES})
ELSE()

View File

@@ -172,7 +172,7 @@ std::string uBytes2Hex(const char * bytes, unsigned int bytesLen)
std::vector<char> uHex2Bytes(const std::string & hex)
{
return uHex2Bytes(&hex[0], hex.length());
return uHex2Bytes(&hex[0], (int)hex.length());
}
std::vector<char> uHex2Bytes(const char * hex, int hexLen)
@@ -287,7 +287,11 @@ std::string uFormatv (const char *fmt, va_list args)
#endif
// Try to vsnprintf into our buffer.
#ifdef _MSC_VER
int needed = vsnprintf_s(buf, size, size, fmt, argsTmp);
#else
int needed = vsnprintf (buf, size, fmt, argsTmp);
#endif
va_end(argsTmp);
// NB. C99 (which modern Linux and OS X follow) says vsnprintf
// failure returns the length it would have needed. But older

View File

@@ -249,7 +249,7 @@ void UDirectory::rewind()
bool UDirectory::exists(const std::string & dirPath)
{
bool r = false;
#if WIN32
#ifdef _WIN32
#ifdef UNICODE
wchar_t * wDirPath = createWCharFromChar(dirPath.c_str());
DWORD dwAttrib = GetFileAttributes(wDirPath);
@@ -273,7 +273,7 @@ bool UDirectory::exists(const std::string & dirPath)
std::string UDirectory::getDir(const std::string & filePath)
{
std::string dir = filePath;
int i=dir.size()-1;
int i=(int)dir.size()-1;
for(; i>=0; --i)
{
if(dir[i] == '/' || dir[i] == '\\')
@@ -333,7 +333,7 @@ std::string UDirectory::currentDir(bool trailingSeparator)
bool UDirectory::makeDir(const std::string & dirPath)
{
int status;
#if WIN32
#ifdef _WIN32
status = _mkdir(dirPath.c_str());
#else
status = mkdir(dirPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
@@ -344,7 +344,7 @@ bool UDirectory::makeDir(const std::string & dirPath)
bool UDirectory::removeDir(const std::string & dirPath)
{
int status;
#if WIN32
#ifdef _WIN32
status = _rmdir(dirPath.c_str());
#else
status = rmdir(dirPath.c_str());
@@ -355,7 +355,7 @@ bool UDirectory::removeDir(const std::string & dirPath)
std::string UDirectory::homeDir()
{
std::string path;
#if WIN32
#ifdef _WIN32
#ifdef UNICODE
wchar_t wProfilePath[250];
ExpandEnvironmentStrings(L"%userprofile%",wProfilePath,250);

View File

@@ -36,12 +36,12 @@ bool UFile::exists(const std::string &filePath)
long UFile::length(const std::string &filePath)
{
long fileSize = 0;
FILE* fp = 0;
long fileSize = 0;
FILE* fp = 0;
#ifdef _MSC_VER
fopen_s(&fp, filePath.c_str(), "rb");
#else
fp = fopen(filePath.c_str(), "rb");
fopen_s(&fp, filePath.c_str(), "rb");
#else
fp = fopen(filePath.c_str(), "rb");
#endif
if(fp == NULL)
{
@@ -70,7 +70,7 @@ std::string UFile::getName(const std::string & filePath)
{
std::string fullPath = filePath;
std::string name;
for(int i=fullPath.size()-1; i>=0; --i)
for(int i=(int)fullPath.size()-1; i>=0; --i)
{
if(fullPath[i] == '/' || fullPath[i] == '\\')
{

View File

@@ -90,7 +90,7 @@ void UThread::join(bool killFirst)
uSleep(1);
}
#if WIN32
#ifdef _WIN32
#if PRINT_DEBUG
UDEBUG("Thread %d joining %d", UThreadC<void>::Self(), threadId_);
#endif