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