{"thread":{"id":"32797","subject":"[PATCH 1/5] msvc: Fix compilation errors caused by poll.h emulation","startedAt":"2013-01-31T18:28:35Z","lastAt":"2013-05-09T21:12:28Z","messageCount":4,"participants":["Ramsay Jones","Sven Strickroth"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"208382","messageId":"510AB7D3.7010407@ramsay1.demon.co.uk","threadId":"32797","inReplyTo":null,"subject":"[PATCH 1/5] msvc: Fix compilation errors caused by poll.h emulation","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-01-31T18:28:35Z","receivedAt":"2013-01-31T18:28:35Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nCommit 0f77dea9 (\"mingw: move poll out of sys-folder\", 24-10-2011), along\nwith other commits in the 'ef/mingw-upload-archive' branch (see commit\n7406aa20), effectively reintroduced the same problem addressed by commit\n56fb3ddc (\"msvc: Fix compilation errors in compat/win32/sys/poll.c\",\n04-12-2010).\n\nIn order to fix the compilation errors, we use the same solution adopted\nin that earlier commit. In particular, we set _WIN32_WINNT to 0x0502\n(which would target Windows Server 2003) prior to including the winsock2.h\nheader file.\n\nAlso, we delete the compat/vcbuild/include/sys/poll.h header file, since\nit is now redundant and it's presence may cause some confusion.\n\nSigned-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>\n---\n compat/vcbuild/include/sys/poll.h | 1 -\n git-compat-util.h                 | 3 +++\n 2 files changed, 3 insertions(+), 1 deletion(-)\n delete mode 100644 compat/vcbuild/include/sys/poll.h\n\ndiff --git a/compat/vcbuild/include/sys/poll.h b/compat/vcbuild/include/sys/poll.h\ndeleted file mode 100644\nindex 0d8552a..0000000\n--- a/compat/vcbuild/include/sys/poll.h\n+++ /dev/null\n@@ -1 +0,0 @@\n-/* Intentionally empty file to support building git with MSVC */\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex cc2abee..204cb1e 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -86,6 +86,9 @@\n #define _SGI_SOURCE 1\n \n #ifdef WIN32 /* Both MinGW and MSVC */\n+# if defined (_MSC_VER)\n+#  define _WIN32_WINNT 0x0502\n+# endif\n #define WIN32_LEAN_AND_MEAN  /* stops windows.h including winsock.h */\n #include <winsock2.h>\n #include <windows.h>\n-- \n1.8.1\n"},{"id":"216749","messageId":"518AFEFC.8010904@cs-ware.de","threadId":"32797","inReplyTo":"510AB7D3.7010407@ramsay1.demon.co.uk","subject":"Re: [PATCH 1/5] msvc: Fix compilation errors caused by poll.h emulation","fromName":"Sven Strickroth","fromEmail":"sven@cs-ware.de","sentAt":"2013-05-09T01:42:20Z","receivedAt":"2013-05-09T01:42:20Z","isPatch":true,"sender":{"key":"sven@cs-ware.de","avatar":null},"body":"Am 31.01.2013 19:28 schrieb Ramsay Jones:\n> Commit 0f77dea9 (\"mingw: move poll out of sys-folder\", 24-10-2011), along\n> with other commits in the 'ef/mingw-upload-archive' branch (see commit\n> 7406aa20), effectively reintroduced the same problem addressed by commit\n> 56fb3ddc (\"msvc: Fix compilation errors in compat/win32/sys/poll.c\",\n> 04-12-2010).\n> \n> In order to fix the compilation errors, we use the same solution adopted\n> in that earlier commit. In particular, we set _WIN32_WINNT to 0x0502\n> (which would target Windows Server 2003) prior to including the winsock2.h\n> header file.\n\nThis change causes problems compiling with MSVC2012 for me. If I don't\ndefine NO_SYS_POLL_H git-compat-util.h now tries to include <sys/poll.h>\nwhich does not exist for MSVC and if I define NO_SYS_POLL_H\ngit-compat-util.h now tries to include <poll.h> which also doesn't exist\nfor MSVC.\n\nIncluding compat/poll into the includes path causes redefinition errors.\n\nHow have you tested this?\n\nI think the check in git-compat-util.h has to be extended to only\ninclude any poll.h if _MSC_VER is defined.\n\n-- \nBest regards,\n Sven Strickroth\n PGP key id F5A9D4C4 @ any key-server\n"},{"id":"216815","messageId":"518C0890.9050508@ramsay1.demon.co.uk","threadId":"32797","inReplyTo":"518AFEFC.8010904@cs-ware.de","subject":"Re: [PATCH 1/5] msvc: Fix compilation errors caused by poll.h emulation","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsay1.demon.co.uk","sentAt":"2013-05-09T20:35:28Z","receivedAt":"2013-05-09T20:35:28Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"Sven Strickroth wrote:\n> Am 31.01.2013 19:28 schrieb Ramsay Jones:\n>> Commit 0f77dea9 (\"mingw: move poll out of sys-folder\", 24-10-2011), along\n>> with other commits in the 'ef/mingw-upload-archive' branch (see commit\n>> 7406aa20), effectively reintroduced the same problem addressed by commit\n>> 56fb3ddc (\"msvc: Fix compilation errors in compat/win32/sys/poll.c\",\n>> 04-12-2010).\n>>\n>> In order to fix the compilation errors, we use the same solution adopted\n>> in that earlier commit. In particular, we set _WIN32_WINNT to 0x0502\n>> (which would target Windows Server 2003) prior to including the winsock2.h\n>> header file.\n> \n> This change causes problems compiling with MSVC2012 for me. If I don't\n> define NO_SYS_POLL_H git-compat-util.h now tries to include <sys/poll.h>\n> which does not exist for MSVC and if I define NO_SYS_POLL_H\n> git-compat-util.h now tries to include <poll.h> which also doesn't exist\n> for MSVC.\n> \n> Including compat/poll into the includes path causes redefinition errors.\n> \n> How have you tested this?\n\nI used the Makefile, with the Visual C++ 2008 command line compiler on\nWindows XP (SP3), to build a vanilla git on MinGW.\nViz:\n\n    ramsay (pu) ms $ git checkout master\n    Switched to branch 'master'\n    ramsay (master) ms $ git rev-parse master\n    423ecb0bb66e9d60b6667aebc2844e82205369a1\n    ramsay (master) ms $ make clean >/dev/null 2>&1\n    ramsay (master) ms $ make >ms-out1 2>&1\n    ramsay (master) ms $ grep error ms-out1\n    ramsay (master) ms $ ./git version\n    git version 1.8.3.rc1.25.g423ecb0.MSVC\n    ramsay (master) ms $\n\nAlso\n\n    ramsay (tmp) ms $ rm git.o\n    ramsay (tmp) ms $ make V=1 git.o\n    compat/vcbuild/scripts/clink.pl -o git.o -c    -nologo -I. -I../zlib -Icompat/vc\n    build -Icompat/vcbuild/include -DWIN32 -D_CONSOLE -DHAVE_STRING_H -D_CRT_SECURE_\n    NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -GL -Os -MT -DNO_CURL -DNO_ST_BLOCKS_IN_\n    STRUCT_STAT -DNO_NSEC -DNO_SYMLINK_HEAD -DNO_GETTEXT -DNO_SYS_POLL_H -DNO_THREAD\n    _SAFE_PREAD -DNO_IPV6 -DNO_INET_NTOP -DNO_INET_PTON -DNO_ICONV -DNO_POSIX_GOODIE\n    S  -DUNRELIABLE_FSTAT -DSHA1_HEADER='\"block-sha1/sha1.h\"' -D__USE_MINGW_ACCESS -\n    DNOGDI -DHAVE_STRING_H -DHAVE_ALLOCA_H -Icompat -Icompat/regex -Icompat/win32 -D\n    STRIP_EXTENSION=\\\".exe\\\" -DNO_LIBGEN_H -DSNPRINTF_RETURNS_BOGUS -DNO_POLL -Icomp\n    at/poll -DNO_STRCASESTR -DNO_STRLCPY -DNO_STRTOUMAX -Icompat/fnmatch -DNO_FNMATC\n    H -DNO_SETENV -DNO_MKDTEMP -DNO_MKSTEMPS -DNO_UNSETENV -DUSE_WIN32_MMAP -DOBJECT\n    _CREATION_MODE=1 -DNO_PREAD -DNO_MEMMEM -DRUNTIME_PREFIX -Icompat/regex -DSHELL_\n    PATH='\"/bin/sh\"' -DDEFAULT_HELP_FORMAT='\"html\"' '-DGIT_HTML_PATH=\"share/doc/git-\n    doc\"' '-DGIT_MAN_PATH=\"share/man\"' '-DGIT_INFO_PATH=\"share/info\"' git.c\n    git.c\n    git.c(204) : warning C4090: 'function' : different 'const' qualifiers\n    git.c(218) : warning C4090: 'function' : different 'const' qualifiers\n    git.c(221) : warning C4090: 'function' : different 'const' qualifiers\n    ramsay (tmp) ms $\n\nNote that '-Icompat/poll' is passed on the command-line (it is split at -Icomp\nabove), which comes from:\n\n    ramsay (tmp) ms $ git grep -n 'compat/poll'\n    Makefile:647:LIB_H += compat/poll/poll.h\n    Makefile:1235:  COMPAT_CFLAGS += -DNO_POLL -Icompat/poll\n    Makefile:1236:  COMPAT_OBJS += compat/poll/poll.o\n    ramsay (tmp) ms $\n\nI have a patch which allows me to generate the preprocessed output file\nand, after running it on git.c (=> git.i), I can see that msvc reads the\ncompat/poll/poll.h file. (from line 128 of git-compat-util.h).\n\nAre you using a MSVC \"project\" file? If so, is it equivalent to the Makefile?\nHas the \"#include\" behaviour changed between MSVC 2008 -> MSVC 2012?\n\nATB,\nRamsay Jones\n"},{"id":"216818","messageId":"518C113C.3080106@cs-ware.de","threadId":"32797","inReplyTo":"518C0890.9050508@ramsay1.demon.co.uk","subject":"Re: [PATCH 1/5] msvc: Fix compilation errors caused by poll.h emulation","fromName":"Sven Strickroth","fromEmail":"sven@cs-ware.de","sentAt":"2013-05-09T21:12:28Z","receivedAt":"2013-05-09T21:12:28Z","isPatch":true,"sender":{"key":"sven@cs-ware.de","avatar":null},"body":"Am 09.05.2013 22:35 schrieb Ramsay Jones:\n> Note that '-Icompat/poll' is passed on the command-line (it is split at -Icomp\n> above), which comes from:\n> \n>     ramsay (tmp) ms $ git grep -n 'compat/poll'\n>     Makefile:647:LIB_H += compat/poll/poll.h\n>     Makefile:1235:  COMPAT_CFLAGS += -DNO_POLL -Icompat/poll\n>     Makefile:1236:  COMPAT_OBJS += compat/poll/poll.o\n>     ramsay (tmp) ms $\n> \n> I have a patch which allows me to generate the preprocessed output file\n> and, after running it on git.c (=> git.i), I can see that msvc reads the\n> compat/poll/poll.h file. (from line 128 of git-compat-util.h).\n> \n> Are you using a MSVC \"project\" file? If so, is it equivalent to the Makefile?\n> Has the \"#include\" behaviour changed between MSVC 2008 -> MSVC 2012?\n\nThank you for your explanation. The problem for me was, that\n_WIN32_WINNT was set to 0x0600 and thus winsck2.h was also declaring pollfd.\n\nBuilding libgit works now.\n\n-- \nBest regards,\n Sven Strickroth\n PGP key id F5A9D4C4 @ any key-server\n"}]}