git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 09/14] Avoid including windows.h in winansi.c for MSVC build

From
Marius Storm-Olsen <mstormo@gmail.com>
Date
Aug 22, 2009, 11:40 UTC
Message-ID
<18cd41840908220440o37cf0909l15ff552abd52e075@mail.gmail.com>
In-Reply-To
<3f4fd2640908211416i489b6e23s27cb9cae6a439ddc@mail.gmail.com>
On Fri, Aug 21, 2009 at 11:16 PM, Reece Dunn<msclrhd@googlemail.com> wrote:
Show 44 quoted lines
> 2009/8/21 Junio C Hamano <gitster@pobox.com>:
>> Marius Storm-Olsen <mstormo@gmail.com> writes:
>>
>>> From: Frank Li <lznuaa@gmail.com>
>>>
>>> compat/msvc.h includes winsock2.h which conflicts with windows.h.
>>> msvc.h also defines the oldest Windows API version required.
>>
>> The first sentence sort-of makes sense; compat/msvc.h will be included by
>> git-compat-util.h and including <windows.h> here will bring conflicting
>> definitions, so we avoid doing so when on MSC.
>>
>> The second sentence does not make any sense to me.  It may be correctly
>> stating a fact (i.e. "defines required WAPI version"), but it is unclear
>> what relevance it has to this change to stop including <windows.h>.
>
> The way things are configured, windows.h is pulling in winsock.h. In
> git-compat-util.h, winsock2.h is included which has conflicting
> definitions of various functions and data structures.
>
>> Having said that, the first sentence hints me that perhaps you guys should
>> include (conditionally only on windows but not with MSC) <windows.h> not
>> from this file, but from git-compat-util.h?
>
> It would make sense for windows.h to be included in git-compat-util.h.
>
> According to http://social.msdn.microsoft.com/Forums/en-US/windowssdk/thread/4a90b143-1fb8-43e9-a54c-956127e0c579,
> the following will work:
>
> #define _WINSOCKAPI_    // stops windows.h including winsock.h
> #include <winsock2.h>
> #include <windows.h>
>
> Also, if you define WIN32_LEAN_AND_MEAN, windows.h will pull in a
> subset of the Windows header files (which also improves compilation
> times). Adding this may prevent it from pulling in winsock.h. This
> would be a better approach (and would make sense to go into
> git-compat-util.h).
>
> I don't have access to a Windows dev box at the moment, so can't
> verify that this does indeed work.
>
> - Reece
>

I'll check this on Monday, and send out a v3 of the series, incorporating the pieces commented on, and clarifying some of the still confusing commit msgs.

-- .marius

Previous: Reece DunnNext: Paolo Bonzini
Message 28 of 49 in “Build git with MSVC”
  1. 00/14 Build git with MSVCMarius Storm-Olsen, Aug 21, 2009
  2. 01/14 Fix non-constant array creationMarius Storm-Olsen, Aug 21, 2009
  3. 02/14 Avoid declaration after statementMarius Storm-Olsen, Aug 21, 2009
  4. 03/14 Define SNPRINTF_SIZE_CORR=1 for Microsoft Visual C++Marius Storm-Olsen, Aug 21, 2009
  5. 04/14 Add define guards to compat/win32.hMarius Storm-Olsen, Aug 21, 2009
  6. 05/14 Change regerror() declaration from K&R style to ANSI C (C89)Marius Storm-Olsen, Aug 21, 2009
  7. 06/14 mingw.c: Use the O_BINARY flag to open filesMarius Storm-Olsen, Aug 21, 2009
  8. 07/14 Fix __stdcall/WINAPI placement and function prototypeMarius Storm-Olsen, Aug 21, 2009
  9. 08/14 Test for WIN32 instead of __MINGW32_Marius Storm-Olsen, Aug 21, 2009
  10. 09/14 Avoid including windows.h in winansi.c for MSVC buildMarius Storm-Olsen, Aug 21, 2009
  11. 10/14 Add empty header files for MSVC portMarius Storm-Olsen, Aug 21, 2009
  12. 11/14 Add MinGW header files to build git with MSVCMarius Storm-Olsen, Aug 21, 2009
  13. 12/14 Add platform files for MSVC portingMarius Storm-Olsen, Aug 21, 2009
  14. 13/14 Add MSVC project filesMarius Storm-Olsen, Aug 21, 2009
  15. 14/14 Add README and gitignore file for MSVC buildMarius Storm-Olsen, Aug 21, 2009
  16. Thiago FarinaAug 23, 2009
  17. Reece DunnAug 23, 2009
  18. Marius Storm-OlsenAug 23, 2009
  19. Thiago FarinaAug 23, 2009
  20. Marius Storm-OlsenAug 24, 2009
  21. Frank LiAug 25, 2009
  22. Thiago FarinaAug 25, 2009
  23. Frank LiAug 27, 2009
  24. Thiago FarinaAug 27, 2009
  25. Erik Faye-LundSep 7, 2009
  26. Junio C HamanoAug 21, 2009
  27. Reece DunnAug 21, 2009
  28. Marius Storm-OlsenAug 22, 2009
  29. Paolo BonziniAug 28, 2009
  30. Johannes SixtAug 21, 2009
  31. Marius Storm-OlsenAug 21, 2009
  32. Frank LiAug 21, 2009
  33. 05/14 Change regerror() definition from K&R style to ANSI C (C89)Marius Storm-Olsen, Aug 21, 2009
  34. Frank LiAug 22, 2009
  35. Erik Faye-LundAug 24, 2009
  36. Junio C HamanoAug 21, 2009
  37. Johan 't HartAug 21, 2009
  38. Johannes SixtAug 21, 2009
  39. Junio C HamanoAug 21, 2009
  40. Marius Storm-OlsenAug 22, 2009
  41. Marius Storm-OlsenAug 22, 2009
  42. Erik Faye-LundAug 21, 2009
  43. Marius Storm-OlsenAug 21, 2009
  44. Janos LaubeAug 21, 2009
  45. Marius Storm-OlsenAug 21, 2009
  46. Johan 't HartAug 21, 2009
  47. Erik Faye-LundAug 22, 2009
  48. Junio C HamanoAug 21, 2009
  49. Junio C HamanoAug 21, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.