Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Winsock2 should be included before any windows.h include.
That's because there are duplicate #defines, and when Winsock2 is defined before windows.h then windows.h detects that and prevent redefinition.
That is the official way stated by Microsoft.
  • Loading branch information
danielgindi committed Aug 29, 2014
commit d5dd91312d288525ef9715892426d843f9e4c4eb
7 changes: 5 additions & 2 deletions src/libvncclient/vncviewer.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
* vncviewer.c - the Xt-based VNC viewer.
*/

#ifdef WIN32
#undef SOCKET
#include <winsock2.h>
#endif

#ifdef __STRICT_ANSI__
#define _BSD_SOURCE
#define _POSIX_SOURCE
Expand All @@ -45,8 +50,6 @@ static void DummyRect(rfbClient* client, int x, int y, int w, int h) {
static char* NoPassword(rfbClient* client) {
return strdup("");
}
#undef SOCKET
#include <winsock2.h>
#define close closesocket
#else
#include <stdio.h>
Expand Down
11 changes: 6 additions & 5 deletions src/rfb/rfbclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
/**
* @file rfbclient.h
*/

#ifdef WIN32
#undef SOCKET
#undef socklen_t
#include <ws2tcpip.h>
#endif

#include <stdio.h>
#include <stdlib.h>
Expand All @@ -38,11 +44,6 @@
#include <unistd.h>
#include <rfb/rfbproto.h>
#include <rfb/keysym.h>
#ifdef __MINGW32__
#undef SOCKET
#undef socklen_t
#include <ws2tcpip.h>
#endif

#define rfbClientSwap16IfLE(s) \
(*(char *)&client->endianTest ? ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff)) : (s))
Expand Down