winefile: UNICODE

Ralf Reiterer ralfreit at
Sun Jul 3 14:01:04 CDT 2005

> No, I don't need tchar.h in 'unixcalls.c'. I only needed it 
> for 'winefile.c'. The problem is, if I add 'include/msvcrt' 
> to the include path, it is added to both files at the same time.

I see. What about adding a separate rule to just for
unixcalls.c and omit that file from C_SRC? That way you can control
again which parameters will be passed to gcc. As unixcalls.c is not a
"traditional" windows source file, but a bridge to the Unix system, I
think that approach should be OK.

> But the biggest problem I forgot about before is wsprintf(). Wine's
> wsprintf() implementation only handles 64 bit integer formats ("%Ld",
> "%Lx") when using msvcrt. So I will have to use LoadLibrary() and
> GetProcAddress() to call vswprintf() for this string formats.

According to MSDN, wsprintf() does not handle INT64 et all. So Wine is
correct when it does not either.

So dynamically linking to msvcrt seems to be the only possible solution.

> I thought it is not allowed to use the "-fshort-wchar" option 
> in Wine because not all compilers support it? If it is - 
> using which macro should one add it to Anyways - 
> I don't need it, because there are no more literal wide 
> string character constants.

You are right, it is NOT allowed in Wine code since it's not portable
between compilers. There WCHAR[] is the right choice. However it is for
Winelib applications (at least the docs suggest it). As Winefile is on
one hand a Winelib application but on the other part of the official
Wine distribution, I recommend to use WCHAR[] when you need Unicode
string literals - that's the safe side. ;-)

> CharUpperW() ...
> What a hack!  ;-)

There are many Windows API functions that use a similar pattern. For
example the resource loading functions like LoadIcon() do the same, i.e.
they interpret the given resource name as WORD if HIWORD(pszResource) is
0 or as string otherwise. That's what MAKEINTRESOURCE() is all about. I
call it the C way of "function overloading". ;-)


More information about the wine-devel mailing list