From 38a807ae6eed6a9232ffc2b5c3220877f260580a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 16 Jun 2011 15:57:40 +0000 Subject: [PATCH] Windows warning fixes --- examples/osgcluster/receiver.cpp | 8 ++++---- src/OpenThreads/win32/Win32Thread.cpp | 2 +- src/osgPlugins/shp/ESRIShape.cpp | 2 +- src/osgPlugins/zip/unzip.cpp | 13 +++++++++++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/examples/osgcluster/receiver.cpp b/examples/osgcluster/receiver.cpp index eaa6ba1e3..864ab7ef8 100644 --- a/examples/osgcluster/receiver.cpp +++ b/examples/osgcluster/receiver.cpp @@ -123,11 +123,11 @@ void Receiver::sync( void ) } #if defined(__linux) || defined(__FreeBSD__) || defined( __APPLE__ ) - socklen_t + socklen_t size; #else - int + int size; #endif - size = sizeof( struct sockaddr_in ); + size = sizeof( struct sockaddr_in ); fd_set fdset; FD_ZERO( &fdset ); @@ -144,7 +144,7 @@ void Receiver::sync( void ) int err = WSAGetLastError (); if (err!=0) fprintf( stderr, "Receiver::sync() - error %d\n",err ); - while( select( _so+1, &fdset, 0L, 0L, &tv ) ) + while( select( static_cast(_so)+1, &fdset, 0L, 0L, &tv ) ) { if( FD_ISSET( _so, &fdset ) ) { diff --git a/src/OpenThreads/win32/Win32Thread.cpp b/src/OpenThreads/win32/Win32Thread.cpp index b3135a277..76e33f7fb 100644 --- a/src/OpenThreads/win32/Win32Thread.cpp +++ b/src/OpenThreads/win32/Win32Thread.cpp @@ -344,7 +344,7 @@ int Thread::start() { pd->threadStartedBlock.reset(); - pd->tid.set( (void*)_beginthreadex(NULL,pd->stackSize,ThreadPrivateActions::StartThread,static_cast(this),0,&ID)); + pd->tid.set( (void*)_beginthreadex(NULL,static_cast(pd->stackSize),ThreadPrivateActions::StartThread,static_cast(this),0,&ID)); pd->uniqueId = (int)ID; diff --git a/src/osgPlugins/shp/ESRIShape.cpp b/src/osgPlugins/shp/ESRIShape.cpp index de1932747..492f1acac 100644 --- a/src/osgPlugins/shp/ESRIShape.cpp +++ b/src/osgPlugins/shp/ESRIShape.cpp @@ -5,7 +5,7 @@ namespace esri { - int read(int fd, void * buf, size_t nbytes) { return _read(fd, buf, nbytes); } + int read(int fd, void * buf, size_t nbytes) { return _read(fd, buf, static_cast(nbytes)); } } #else diff --git a/src/osgPlugins/zip/unzip.cpp b/src/osgPlugins/zip/unzip.cpp index dca61bf5b..5b9ae05d5 100644 --- a/src/osgPlugins/zip/unzip.cpp +++ b/src/osgPlugins/zip/unzip.cpp @@ -128,6 +128,15 @@ #endif #endif +// workaround for Windows warnings. +#if defined(_MSC_VER) + #define FILENO _fileno + #define GETCWD _getcwd +#else + #define FILENO fileno + #define GETCWD getcwd +#endif + #define ZIP_HANDLE 1 @@ -188,7 +197,7 @@ typedef struct tm_unz_s // some windows<->linux portability things #ifdef ZIP_STD DWORD GetFilePosU(HANDLE hfout) -{ struct stat st; fstat(fileno(hfout),&st); +{ struct stat st; fstat(FILENO(hfout),&st); if ((st.st_mode&S_IFREG)==0) return 0xFFFFFFFF; return ftell(hfout); } @@ -3928,7 +3937,7 @@ ZRESULT TUnzip::Open(void *z,unsigned int len,DWORD flags) { if (uf!=0 || currentfile!=-1) return ZR_NOTINITED; // #ifdef ZIP_STD - char* buf = getcwd(rootdir,MAX_PATH-1); + char* buf = GETCWD(rootdir,MAX_PATH-1); if (buf==0) return ZR_NOFILE; #else #ifdef GetCurrentDirectory