From 54de13c1c7b8e22a3668d4325e77611857071c2a Mon Sep 17 00:00:00 2001 From: iphydf Date: Thu, 8 Sep 2016 00:29:44 +0100 Subject: [PATCH] Fix compilation for Windows. - Mingw32 didn't read MSDN, so behaves badly despite lean and mean. - Avoid alignment issues on windows with packed bitfields in the RTP header. This change makes the program ill-formed in C99, but I don't know the correct fix at the moment, and I don't want to keep the Windows build broken for too long. --- toxav/rtp.h | 24 ++++++++++++------------ toxcore/network.h | 11 ++++------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/toxav/rtp.h b/toxav/rtp.h index 4d60682a..18929e12 100644 --- a/toxav/rtp.h +++ b/toxav/rtp.h @@ -37,21 +37,21 @@ enum { struct RTPHeader { /* Standard RTP header */ #ifndef WORDS_BIGENDIAN - unsigned cc: 4; /* Contributing sources count */ - unsigned xe: 1; /* Extra header */ - unsigned pe: 1; /* Padding */ - unsigned ve: 2; /* Version */ + uint16_t cc: 4; /* Contributing sources count */ + uint16_t xe: 1; /* Extra header */ + uint16_t pe: 1; /* Padding */ + uint16_t ve: 2; /* Version */ - unsigned pt: 7; /* Payload type */ - unsigned ma: 1; /* Marker */ + uint16_t pt: 7; /* Payload type */ + uint16_t ma: 1; /* Marker */ #else - unsigned ve: 2; /* Version */ - unsigned pe: 1; /* Padding */ - unsigned xe: 1; /* Extra header */ - unsigned cc: 4; /* Contributing sources count */ + uint16_t ve: 2; /* Version */ + uint16_t pe: 1; /* Padding */ + uint16_t xe: 1; /* Extra header */ + uint16_t cc: 4; /* Contributing sources count */ - unsigned ma: 1; /* Marker */ - unsigned pt: 7; /* Payload type */ + uint16_t ma: 1; /* Marker */ + uint16_t pt: 7; /* Payload type */ #endif uint16_t sequnum; diff --git a/toxcore/network.h b/toxcore/network.h index cf4948de..dd654b8d 100644 --- a/toxcore/network.h +++ b/toxcore/network.h @@ -44,15 +44,12 @@ #define WINVER 0x0501 #endif -// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms737629(v=vs.85).aspx -// for why. In short: we need to avoid inclusion of by , -// so doesn't cause issues. -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif +// The mingw32/64 Windows library warns about including winsock2.h after +// windows.h even though with the above it's a valid thing to do. So, to make +// mingw32 headers happy, we include winsock2.h first. +#include #include -#include #include #ifndef IPV6_V6ONLY