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

Re: [PATCH] compat/mingw.c: MSVC build must use ANSI Win32 API's

From
Marius Storm-Olsen <mstormo@gmail.com>
Date
Sep 22, 2009, 07:23 UTC
Message-ID
<4AB87B6B.1070808@gmail.com>
In-Reply-To
<4AB869EE.1020200@viscovery.net>
Johannes Sixt said the following on 22.09.2009 08:08:
Show 14 quoted lines
> Michael Wookey schrieb:
>> MSVC builds define UNICODE which results in the "WIDE" variation of
>> Win32 API's being used.
>>
>> Explicitly use the ANSI variation of the API's for compatibility with
>> msysgit.
>>
>> Signed-off-by: Michael Wookey <michaelwookey@gmail.com>
> 
> Marius,
> 
> I would like to understand why you did not have this issue.
> 
> The patch itself looks fine.

I never added the UNICODE define to the Git compile process with MSVC (Check the Makefile), so then the windows API should use the ANSI version by default. And the following patch proved my point (sorry, will probably wrap):

--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -1201,6 +1201,12 @@ struct mingw_DIR
        char                    dd_name[1];     /* given path for dir with search pattern (struct is extended) */
 };

+#ifdef UNICODE
+#pragma message("We have UNICODE defined")
+#else
+#pragma message("Nope, UNICODE is not defined here")
+#endif
+
 struct dirent *mingw_readdir(DIR *dir)
 {
        WIN32_FIND_DATAA buf;


> make MSVC=1
    CC compat/msvc.o
msvc.c
d:\msvc\git\compat\mingw.c(223) : warning C4133: 'function' : incompatible types - from '_stati64 *' to '_stat64 *'
d:\msvc\git\compat\mingw.c(636) : warning C4090: 'initializing' : different 'const' qualifiers
d:\msvc\git\compat\mingw.c(637) : warning C4090: 'initializing' : different 'const' qualifiers
d:\msvc\git\compat\mingw.c(787) : warning C4090: 'function' : different 'const' qualifiers
d:\msvc\git\compat\mingw.c(797) : warning C4090: 'function' : different 'const' qualifiers
Nope, UNICODE is not defined here
    AR libgit.a
Microsoft (R) Library Manager Version 9.00.21022.08
Copyright (C) Microsoft Corporation.  All rights reserved.

Michael, how are you trying to compile git? With the IDE or
the GNU Make? Which version of MSVC? If you use the IDE, can
you make sure it doesn't contain the UNICODE define in the
compiler section of the properties of the projects?

In general though, I'm ok with patches which specifies the
correct API, so we won't have the problem, should we decide
to add UNICODE in the future.

--
.marius
Previous: Johannes SixtNext: Michael Wookey
Message 3 of 13 in “compat/mingw.c: MSVC build must use ANSI Win32 API's”
  1. compat/mingw.c: MSVC build must use ANSI Win32 API'sMichael Wookey, Sep 22, 2009
  2. Johannes SixtSep 22, 2009
  3. Marius Storm-OlsenSep 22, 2009
  4. Michael WookeySep 22, 2009
  5. Marius Storm-OlsenSep 22, 2009
  6. Michael WookeySep 22, 2009
  7. Michael WookeySep 23, 2009
  8. Johannes SixtSep 28, 2009
  9. Michael WookeySep 28, 2009
  10. Johannes SixtSep 28, 2009
  11. Michael WookeySep 28, 2009
  12. Michael WookeySep 28, 2009
  13. Marius Storm-OlsenSep 28, 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.