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.
This commit is contained in:
iphydf 2016-09-08 00:29:44 +01:00
parent d5f9344847
commit 54de13c1c7
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
2 changed files with 16 additions and 19 deletions

View File

@ -37,21 +37,21 @@ enum {
struct RTPHeader { struct RTPHeader {
/* Standard RTP header */ /* Standard RTP header */
#ifndef WORDS_BIGENDIAN #ifndef WORDS_BIGENDIAN
unsigned cc: 4; /* Contributing sources count */ uint16_t cc: 4; /* Contributing sources count */
unsigned xe: 1; /* Extra header */ uint16_t xe: 1; /* Extra header */
unsigned pe: 1; /* Padding */ uint16_t pe: 1; /* Padding */
unsigned ve: 2; /* Version */ uint16_t ve: 2; /* Version */
unsigned pt: 7; /* Payload type */ uint16_t pt: 7; /* Payload type */
unsigned ma: 1; /* Marker */ uint16_t ma: 1; /* Marker */
#else #else
unsigned ve: 2; /* Version */ uint16_t ve: 2; /* Version */
unsigned pe: 1; /* Padding */ uint16_t pe: 1; /* Padding */
unsigned xe: 1; /* Extra header */ uint16_t xe: 1; /* Extra header */
unsigned cc: 4; /* Contributing sources count */ uint16_t cc: 4; /* Contributing sources count */
unsigned ma: 1; /* Marker */ uint16_t ma: 1; /* Marker */
unsigned pt: 7; /* Payload type */ uint16_t pt: 7; /* Payload type */
#endif #endif
uint16_t sequnum; uint16_t sequnum;

View File

@ -44,15 +44,12 @@
#define WINVER 0x0501 #define WINVER 0x0501
#endif #endif
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms737629(v=vs.85).aspx // The mingw32/64 Windows library warns about including winsock2.h after
// for why. In short: we need to avoid inclusion of <winsock.h> by <windows.h>, // windows.h even though with the above it's a valid thing to do. So, to make
// so <winsock2.h> doesn't cause issues. // mingw32 headers happy, we include winsock2.h first.
#ifndef WIN32_LEAN_AND_MEAN #include <winsock2.h>
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h> #include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#ifndef IPV6_V6ONLY #ifndef IPV6_V6ONLY