Skip to contentSkip to conversation

MSVC: Compile fix by not including sys/resources.h

PATCH In review Vincent van Ravesteijn 2 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 MSVC: Compile fix by not including sys/resources.h

Fix compilation when compiling with MSVC because sys/resource.h is not available. This patch causes a number of other headerfiles that are not available to be excluded as well.

---
 git-compat-util.h |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
git-compat-util.h +6 -7
index 5ef8ff7..53186da 100644
@@ -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>
@@ -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

--
1.7.6.msysgit.0

#1 lore raw

PATCH 2/3 MSVC: Compile fix by including io.h

Include io.h when compiling with MSVC

---
 compat/msvc.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
compat/msvc.h +1 -0
index a33b01c..aa4b563 100644
@@ -4,6 +4,7 @@
 #include <direct.h>
 #include <process.h>
 #include <malloc.h>
+#include <io.h>
 
 /* porting function */
 #define inline __inline

--
1.7.6.msysgit.0

#2 lore raw

PATCH 3/3 MSVC: Remove unneeded header stubs

In reply to Vincent van Ravesteijn

These headers are not necessary anymore as they are no longer included in git-compat-util.h.

---
 compat/vcbuild/include/arpa/inet.h   |    1 -
 compat/vcbuild/include/grp.h         |    1 -
 compat/vcbuild/include/inttypes.h    |    1 -
 compat/vcbuild/include/netdb.h       |    1 -
 compat/vcbuild/include/netinet/in.h  |    1 -
 compat/vcbuild/include/netinet/tcp.h |    1 -
 compat/vcbuild/include/pwd.h         |    1 -
 compat/vcbuild/include/sys/ioctl.h   |    1 -
 compat/vcbuild/include/sys/select.h  |    1 -
 compat/vcbuild/include/sys/socket.h  |    1 -
 compat/vcbuild/include/sys/wait.h    |    1 -
 compat/vcbuild/include/termios.h     |    1 -
 12 files changed, 0 insertions(+), 12 deletions(-)
 delete mode 100644 compat/vcbuild/include/arpa/inet.h
 delete mode 100644 compat/vcbuild/include/grp.h
 delete mode 100644 compat/vcbuild/include/inttypes.h
 delete mode 100644 compat/vcbuild/include/netdb.h
 delete mode 100644 compat/vcbuild/include/netinet/in.h
 delete mode 100644 compat/vcbuild/include/netinet/tcp.h
 delete mode 100644 compat/vcbuild/include/pwd.h
 delete mode 100644 compat/vcbuild/include/sys/ioctl.h
 delete mode 100644 compat/vcbuild/include/sys/select.h
 delete mode 100644 compat/vcbuild/include/sys/socket.h
 delete mode 100644 compat/vcbuild/include/sys/wait.h
 delete mode 100644 compat/vcbuild/include/termios.h
compat/vcbuild/include/arpa/inet.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/grp.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/inttypes.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/netdb.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/netinet/in.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/netinet/tcp.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/pwd.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/sys/ioctl.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/sys/select.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/sys/socket.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/sys/wait.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
compat/vcbuild/include/termios.h deleted +0 -1
deleted file mode 100644
index 0d8552a..0000000
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
Signature · 1 line
1.7.6.msysgit.0
#3 lore raw
In reply to Vincent van Ravesteijn
Quoted 3 lines
Quoted 3 lines

...
Subject: [PATCH 1/3] MSVC: Compile fix by not including sys/resources.h
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

........................................................^^^^^^

Could you refrain from doing that? It breaks the patch text.

Quoted 5 lines · Vincent van Ravesteijn

Fix compilation when compiling with MSVC because sys/resource.h is not available. This patch causes a number of other headerfiles that are not available to be excluded as well.

Instead of current

	#ifndef mingw32 is the only one that is strange
        ... everything for systems that is not strainge ...
        #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.