[vlc-devel] [vlc-commits] modules: use TEXT() for strings calling wide char Win32 APIs
robux4 at ycbcr.xyz
Thu Apr 4 06:06:19 CEST 2019
> On 3 Apr 2019, at 21:23, Rémi Denis-Courmont <remi at remlab.net> wrote:
> Le keskiviikkona 3. huhtikuuta 2019, 10.56.02 EEST Steve Lhomme a écrit :
>> vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Apr 3 08:52:35
>> 2019 +0200| [238807626113d398df07bbf11caa6efff99fcb09] | committer: Steve
>> modules: use TEXT() for strings calling wide char Win32 APIs
> No. Wide char is L, as in L"foobar".
I don't disagree but it seems I have to explain more since there is some confusion.
On Windows many APIs have two variants: ANSI and Unicode. The ANSI variants are suffixed with A and the Unicode variant suffixed with W. For example SetWindowTextA and SetWindowTextW. Unicode variants take a WCHAR where the ANSI variant takes a CHAR.
Most of the time the code is written without the suffix, for exemple calling SetWindowText. This function doesn't exist and won't link. Depending if you have the UNICODE define set or not will decide which variant it will actually call.
Since the code can theoretically be written to use both, when using string literals you want to use a wide string when building for Unicode and a single byte char in ANSI. The TEXT macro ensures that your string literals match the API variant you're calling.
Another way to do it would be to suffix all our Windows calls with W, and not use the TEXT macro, prefixing all the literal strings with L instead. I'm not sure it's more readable, it's a lot of work but would remove some confusion.
>> _T() is for TCHAR
> AFAIK, TEXT and _T are essentially the same. I don't exactly understand the
> Rémi Denis-Courmont
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
More information about the vlc-devel