From 435bdf8c7ffa493f8f6f2e8f329f8cc22db16ce6 Mon Sep 17 00:00:00 2001 From: Marius Storm-Olsen Date: Wed, 16 Sep 2009 10:20:26 +0200 Subject: Make usage of windows.h lean and mean Centralize the include of windows.h in git-compat-util.h, turn on WIN32_LEAN_AND_MEAN to avoid including plenty of other header files which is not needed in Git. Also ensure we load winsock2.h first, so we don't load the older winsock definitions at a later stage, since they contain duplicate definitions. When moving windows.h into git-compat-util.h, we need to protect the definition of struct pollfd in mingw.h, since this file is used by both MinGW and MSVC, and the latter defines this struct in winsock2.h. We need to keep the windows.h include in compat/win32.h, since its shared by both MinGW and Cygwin, and we're not touching Cygwin in this commit. The include in git-compat-util.h is protected with an ifdef WIN32, which is not the case when compiling for Cygwin. Signed-off-by: Marius Storm-Olsen Acked-by: Johannes Sixt Signed-off-by: Junio C Hamano --- compat/mingw.c | 2 ++ compat/mingw.h | 2 ++ compat/msvc.h | 7 ------- compat/win32.h | 2 ++ compat/winansi.c | 1 - 5 files changed, 6 insertions(+), 8 deletions(-) (limited to 'compat') diff --git a/compat/mingw.c b/compat/mingw.c index 34ee427baf..6b5b5b2c70 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -3,6 +3,8 @@ #include #include "../strbuf.h" +#include + static int err_win_to_posix(DWORD winerr) { int error = ENOSYS; diff --git a/compat/mingw.h b/compat/mingw.h index bcd23b0a45..5b5258bceb 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -41,6 +41,7 @@ struct passwd { extern char *getpass(const char *prompt); +#ifndef POLLIN struct pollfd { int fd; /* file descriptor */ short events; /* requested events */ @@ -48,6 +49,7 @@ struct pollfd { }; #define POLLIN 1 #define POLLHUP 2 +#endif typedef void (__cdecl *sig_handler_t)(int); struct sigaction { diff --git a/compat/msvc.h b/compat/msvc.h index 6daf313e8c..53a6d30c02 100644 --- a/compat/msvc.h +++ b/compat/msvc.h @@ -1,13 +1,6 @@ #ifndef __MSVC__HEAD #define __MSVC__HEAD -/* Define minimize windows version */ -#define WINVER 0x0500 -#define _WIN32_WINNT 0x0500 -#define _WIN32_WINDOWS 0x0410 -#define _WIN32_IE 0x0700 -#define NTDDI_VERSION NTDDI_WIN2KSP1 -#include #include #include #include diff --git a/compat/win32.h b/compat/win32.h index e8c178d8cd..8ce91048de 100644 --- a/compat/win32.h +++ b/compat/win32.h @@ -2,7 +2,9 @@ #define WIN32_H /* common Win32 functions for MinGW and Cygwin */ +#ifndef WIN32 /* Not defined by Cygwin */ #include +#endif static inline int file_attr_to_st_mode (DWORD attr) { diff --git a/compat/winansi.c b/compat/winansi.c index 9217c24b43..dedce2104e 100644 --- a/compat/winansi.c +++ b/compat/winansi.c @@ -2,7 +2,6 @@ * Copyright 2008 Peter Harris */ -#include #include "../git-compat-util.h" /* -- cgit v1.2.1