Skip to content

Commit fd6f6aa

Browse files
vfr-nldscho
authored andcommitted
Compile fix for MSVC: Do not include sys/resources.h
Do not include header files when compiling with MSVC that do not exist and which are also not included when compiling with MINGW. A direct consequence is that git can be compiled again with MSVC because the missing "sys/resources.h" is no longer included. Instead of current #ifndef mingw32 is the only one that is strange ... everything for systems that is not strange ... #else ... include mingw specific tweaks ... #endif #ifdef msvc is also strange ... include msvc specific tweaks ... #endif it turns things around and says what it wants to achieve in a more direct way, i.e. #if mingw32 #include "compat/mingw.h" #elif msvc #include "compat/msvc.h" #else ... all the others ... #endif which makes it look simpler. Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org> Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
1 parent ae69aaf commit fd6f6aa

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

git-compat-util.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@
116116
#else
117117
#include <poll.h>
118118
#endif
119-
#ifndef __MINGW32__
119+
#if defined(__MINGW32__)
120+
/* pull in Windows compatibility stuff */
121+
#include "compat/mingw.h"
122+
#elif defined(_MSC_VER)
123+
#include "compat/msvc.h"
124+
#else
120125
#include <sys/wait.h>
121126
#include <sys/resource.h>
122127
#include <sys/socket.h>
@@ -145,12 +150,6 @@
145150
#include <grp.h>
146151
#define _ALL_SOURCE 1
147152
#endif
148-
#else /* __MINGW32__ */
149-
/* pull in Windows compatibility stuff */
150-
#include "compat/mingw.h"
151-
#endif /* __MINGW32__ */
152-
#ifdef _MSC_VER
153-
#include "compat/msvc.h"
154153
#endif
155154

156155
#ifndef NO_LIBGEN_H

0 commit comments

Comments
 (0)