Use WIN32 for Windows-specific #ifdef guards

To support Microsoft Visual C++, we must not guard Windows-specific code
in MinGW-specific #ifdef guards.

Happily, even 64-bit MSVC defines the WIN32 constant, therefore we can use
that instead.

[JES: fixed commit message, reordered commit, split out unrelated changes]

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
pull/1/head
Daniel Cohen Gindi 10 years ago committed by Johannes Schindelin
parent 4c2cfb17f0
commit 366dda9951

@ -27,11 +27,13 @@
#endif #endif
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef __MINGW32__ #ifdef WIN32
#define close closesocket #define close closesocket
#include <winsock2.h> #include <winsock2.h>
#ifdef _MINGW32
#undef max #undef max
#else #endif // #ifdef _MINGW32
#else // #ifdef WIN32
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#endif #endif
@ -46,7 +48,7 @@
void void
listenForIncomingConnections(rfbClient* client) listenForIncomingConnections(rfbClient* client)
{ {
#ifdef __MINGW32__ #ifdef WIN32
/* FIXME */ /* FIXME */
rfbClientErr("listenForIncomingConnections on MinGW32 NOT IMPLEMENTED\n"); rfbClientErr("listenForIncomingConnections on MinGW32 NOT IMPLEMENTED\n");
return; return;

@ -38,7 +38,9 @@
#ifdef WIN32 #ifdef WIN32
#undef SOCKET #undef SOCKET
#include <winsock2.h> #include <winsock2.h>
#ifdef MINGW32
#define EWOULDBLOCK WSAEWOULDBLOCK #define EWOULDBLOCK WSAEWOULDBLOCK
#endif
#define close closesocket #define close closesocket
#define read(sock,buf,len) recv(sock,buf,len,0) #define read(sock,buf,len) recv(sock,buf,len,0)
#define write(sock,buf,len) send(sock,buf,len,0) #define write(sock,buf,len) send(sock,buf,len,0)
@ -109,7 +111,7 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
diff.tv_sec--; diff.tv_sec--;
diff.tv_usec+=1000000; diff.tv_usec+=1000000;
} }
#ifndef __MINGW32__ #ifndef WIN32
sleep (diff.tv_sec); sleep (diff.tv_sec);
usleep (diff.tv_usec); usleep (diff.tv_usec);
#else #else

@ -45,7 +45,7 @@ static rfbBool DummyPoint(rfbClient* client, int x, int y) {
static void DummyRect(rfbClient* client, int x, int y, int w, int h) { static void DummyRect(rfbClient* client, int x, int y, int w, int h) {
} }
#ifdef __MINGW32__ #ifdef WIN32
static char* NoPassword(rfbClient* client) { static char* NoPassword(rfbClient* client) {
return strdup(""); return strdup("");
} }
@ -56,9 +56,9 @@ static char* NoPassword(rfbClient* client) {
#endif #endif
static char* ReadPassword(rfbClient* client) { static char* ReadPassword(rfbClient* client) {
#ifdef __MINGW32__ #ifdef WIN32
/* FIXME */ /* FIXME */
rfbClientErr("ReadPassword on MinGW32 NOT IMPLEMENTED\n"); rfbClientErr("ReadPassword on Windows NOT IMPLEMENTED\n");
return NoPassword(client); return NoPassword(client);
#else #else
int i; int i;

Loading…
Cancel
Save