Skip to content

Commit

Permalink
Compile fix for MSVC: Do not include sys/resources.h
Browse files Browse the repository at this point in the history
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 a lot simpler.

Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org>
Helped-by: Junio C Hamano <gitster@pobox.com>
Acked-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Vincent van Ravesteijn authored and Junio C Hamano committed Nov 1, 2011
1 parent be3fa91 commit cfc755d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@
#else
#include <poll.h>
#endif
#ifndef __MINGW32__
#if defined(__MINGW32__)
/* pull in Windows compatibility stuff */
#include "compat/mingw.h"
#elif defined(_MSC_VER)
#include "compat/msvc.h"
#else
#include <sys/wait.h>
#include <sys/resource.h>
#include <sys/socket.h>
Expand Down Expand Up @@ -145,12 +150,6 @@
#include <grp.h>
#define _ALL_SOURCE 1
#endif
#else /* __MINGW32__ */
/* pull in Windows compatibility stuff */
#include "compat/mingw.h"
#endif /* __MINGW32__ */
#ifdef _MSC_VER
#include "compat/msvc.h"
#endif

#ifndef NO_LIBGEN_H
Expand Down

0 comments on commit cfc755d

Please sign in to comment.