threads / patch / 28739

patch, 3 partsMSVC: Compile fix by not including sys/resources.h

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

## tl;dr

4 messages between Oct 21, 2011 and Oct 22, 2011. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Vincent van Ravesteijn· Oct 21, 2011, 19:36 UTC · lore

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.

Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org>
---
  git-compat-util.h |   13 ++++++-------
  1 files changed, 6 insertions(+), 7 deletions(-)
Show changes to git-compat-util.h +6 −8
diff --git a/git-compat-util.h b/git-compat-util.h
index 5ef8ff7..53186da 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -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
Vincent van Ravesteijn· Oct 21, 2011, 19:39 UTC · re: Vincent van Ravesteijn · lore

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

Include io.h when compiling with MSVC
Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org>
---
  compat/msvc.h |    1 +
  1 files changed, 1 insertions(+), 0 deletions(-)
Show changes to compat/msvc.h +1 −1
diff --git a/compat/msvc.h b/compat/msvc.h
index a33b01c..aa4b563 100644
--- a/compat/msvc.h
+++ b/compat/msvc.h
@@ -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
Vincent van Ravesteijn· Oct 21, 2011, 19:42 UTC · re: Vincent van Ravesteijn · lore

[PATCH 3/3] MSVC: Remove unneeded header stubs

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

Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org>
---
  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
Show changes to 12 files +0 −12

compat/vcbuild/include/arpa/inet.h, compat/vcbuild/include/grp.h, compat/vcbuild/include/inttypes.h, compat/vcbuild/include/netdb.h, compat/vcbuild/include/netinet/in.h, compat/vcbuild/include/netinet/tcp.h, compat/vcbuild/include/pwd.h, compat/vcbuild/include/sys/ioctl.h, compat/vcbuild/include/sys/select.h, compat/vcbuild/include/sys/socket.h, compat/vcbuild/include/sys/wait.h, compat/vcbuild/include/termios.h

diff --git a/compat/vcbuild/include/arpa/inet.h 
b/compat/vcbuild/include/arpa/inet.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/arpa/inet.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
diff --git a/compat/vcbuild/include/grp.h b/compat/vcbuild/include/grp.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/grp.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
diff --git a/compat/vcbuild/include/inttypes.h 
b/compat/vcbuild/include/inttypes.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/inttypes.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
diff --git a/compat/vcbuild/include/netdb.h b/compat/vcbuild/include/netdb.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/netdb.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
diff --git a/compat/vcbuild/include/netinet/in.h 
b/compat/vcbuild/include/netinet/in.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/netinet/in.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
diff --git a/compat/vcbuild/include/netinet/tcp.h 
b/compat/vcbuild/include/netinet/tcp.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/netinet/tcp.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
diff --git a/compat/vcbuild/include/pwd.h b/compat/vcbuild/include/pwd.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/pwd.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
diff --git a/compat/vcbuild/include/sys/ioctl.h 
b/compat/vcbuild/include/sys/ioctl.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/sys/ioctl.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
diff --git a/compat/vcbuild/include/sys/select.h 
b/compat/vcbuild/include/sys/select.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/sys/select.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
diff --git a/compat/vcbuild/include/sys/socket.h 
b/compat/vcbuild/include/sys/socket.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/sys/socket.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
diff --git a/compat/vcbuild/include/sys/wait.h 
b/compat/vcbuild/include/sys/wait.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/sys/wait.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
diff --git a/compat/vcbuild/include/termios.h 
b/compat/vcbuild/include/termios.h
deleted file mode 100644
index 0d8552a..0000000
--- a/compat/vcbuild/include/termios.h
+++ /dev/null
@@ -1 +0,0 @@
-/* Intentionally empty file to support building git with MSVC */
-- 
1.7.6.msysgit.0
Junio C Hamano· Oct 22, 2011, 00:56 UTC · re: Vincent van Ravesteijn · lore

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

>> ...
>> 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.
Vincent van Ravesteijn <vfr@lyx.org> writes:
Show 5 quoted lines
> 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.
>
> Signed-off-by: Vincent van Ravesteijn <vfr@lyx.org>
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.

← back to recent threads