bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Don't assume that UNICODE is not defined


From: Steve Lhomme
Subject: Re: Don't assume that UNICODE is not defined
Date: Sat, 30 May 2020 16:46:13 +0200 (CEST)

> On May 30, 2020 4:31 PM Bruno Haible <bruno@clisp.org> wrote:
> 
>  
> Steve Lhomme wrote:
> > Why not use the proper call in the first place rather than use a define ?
> > It could be useful in a generic header used by all to make sure everyone
> > uses the right thing. But since you need to edit each file it would be
> > cleaner not to use any define at all and use the proper functions and
> > structures directly.
> 
> It would be possible. But
>   - It is ugly.
>   - The correct search term on microsoft.com, stackoverflow.com, etc. is
>     'LoadLibrary', not 'LoadLibraryA'. Let's speak the same language as
>     everyone else is speaking.

Microsoft.com doesn't document the function as LoadLibrary anymore. There is 
LoadLibraryA and LoadLibraryW.
https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibrarya
https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryw

It even says the following:
The libloaderapi.h header defines LoadLibrary as an alias which automatically 
selects the ANSI or Unicode version of this function based on the definition of 
the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias 
with code that not encoding-neutral can lead to mismatches that result in 
compilation or runtime errors. For more information, see Conventions for 
Function Prototypes.

Given the name of the header that's not what should be used from now on. Using 
the old names gives a sense of safety you don't actually have. Looking at the 
code I would assume, like any currently maintained code, that the default is to 
call UNICODE API's. But I don't find any mention of WideCharToMultiByte or 
CP_UTF8 in the code. And from the patch you did it's quite the opposite.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]