From fe33232f3991796b4c8437016cfe66ac5599f36e Mon Sep 17 00:00:00 2001
From: Matthew Oliver <protogonoi@gmail.com>
Date: Thu, 27 Nov 2014 19:00:36 +1100
Subject: [PATCH] msvc: Fix compilation errors due to header include order.

Ensures that the header include order is such that winsock2.h is always
included before windows.h or that windows.h does not include winsock.h.
---
 libavdevice/dshow_capture.h |  1 +
 libavdevice/opengl_enc.c    |  1 +
 libavformat/matroskadec.c   | 13 +++++++------
 libavutil/atomic_win32.h    |  1 +
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h
index e4b4dce..0252070 100644
--- a/libavdevice/dshow_capture.h
+++ b/libavdevice/dshow_capture.h
@@ -27,6 +27,7 @@
 #include "avdevice.h"
 
 #define COBJMACROS
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #define NO_DSHOW_STRSAFE
 #include <dshow.h>
diff --git a/libavdevice/opengl_enc.c b/libavdevice/opengl_enc.c
index 5f5b800..434ae97 100644
--- a/libavdevice/opengl_enc.c
+++ b/libavdevice/opengl_enc.c
@@ -31,6 +31,7 @@
 #include "config.h"
 
 #if HAVE_WINDOWS_H
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #endif
 #if HAVE_OPENGL_GL3_H
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 3b45c3b..c81b5a04 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -32,12 +32,6 @@
 
 #include <inttypes.h>
 #include <stdio.h>
-#if CONFIG_BZLIB
-#include <bzlib.h>
-#endif
-#if CONFIG_ZLIB
-#include <zlib.h>
-#endif
 
 #include "libavutil/avstring.h"
 #include "libavutil/base64.h"
@@ -62,6 +56,13 @@
 #include "riff.h"
 #include "rmsipr.h"
 
+#if CONFIG_BZLIB
+#include <bzlib.h>
+#endif
+#if CONFIG_ZLIB
+#include <zlib.h>
+#endif
+
 typedef enum {
     EBML_NONE,
     EBML_UINT,
diff --git a/libavutil/atomic_win32.h b/libavutil/atomic_win32.h
index 20b99df..f729933 100644
--- a/libavutil/atomic_win32.h
+++ b/libavutil/atomic_win32.h
@@ -21,6 +21,7 @@
 #ifndef AVUTIL_ATOMIC_WIN32_H
 #define AVUTIL_ATOMIC_WIN32_H
 
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
 #define avpriv_atomic_int_get atomic_int_get_win32
-- 
1.9.4.msysgit.1

