Skip to content

Avoid relying on legacy W vs. A macros #668

@walbourn

Description

@walbourn

Building this code using _UNICODE results in build failures. Per the UTF8-Everywhere Manifesto, if your code requires narrow string you should explicitly use the "A" variants and not rely on these legacy mappings.

When trying to build this library for Xbox which enables _UNICODE, there are numerous errors:

src\consolelogger.c(71): warning C4133: 'function': incompatible types - from 'char [260]' to 'LPWSTR'

Use FormatMessageA instead of FormatMessage and assume the mapping works.

src\consolelogger.c(71): warning C4133: 'function': incompatible types - from 'char [260]' to 'LPWSTR'
src\xlogging.c(123): warning C4133: 'function': incompatible types - from 'char [8]' to 'LPCWSTR'
src\xlogging.c(123): warning C4133: 'function': incompatible types - from 'char [260]' to 'LPWSTR'
src\xlogging.c(126): warning C4133: 'function': incompatible types - from 'char [260]' to 'LPWSTR'
adapters\string_utils.c(142): warning C4133: 'function': incompatible types - from 'char [255]' to 'LPWSTR'
adapters\string_utils.c(150): warning C4133: 'function': incompatible types - from 'char [255]' to 'LPWSTR'
adapters\tlsio_schannel.c(366): warning C4133: 'function': incompatible types - from 'SEC_CHAR *' to 'SEC_WCHAR *'
adapters\tlsio_schannel.c(671): warning C4133: 'function': incompatible types - from 'SEC_CHAR *' to 'SEC_WCHAR *'
adapters\tlsio_schannel.c(830): warning C4477: 'printf' : format string '%s' requires an argument of type 'char *', but variadic argument 2 has type 'LPTSTR'
adapters\tlsio_schannel.c(830): note: consider using '%ls' in the format string
adapters\tlsio_schannel.c(830): note: consider using '%lls' in the format string
adapters\tlsio_schannel.c(830): note: consider using '%Ls' in the format string
adapters\tlsio_schannel.c(830): note: consider using '%ws' in the format string
adapters\tlsio_schannel.c(967): warning C4133: 'function': incompatible types - from 'SEC_CHAR *' to 'SEC_WCHAR *'
'LPTSTR'

Another issue is that tchar usage in general is not a modern pattern, and this code doesn't built for wchar_t anyhow

adapters\tlsio_schannel.c(1016): warning C4477: 'printf' : format string '%s' requires an argument of type 'char *', but variadic argument 2 has type adapters\tlsio_schannel.c(1016): note: consider using '%ls' in the format string
adapters\tlsio_schannel.c(1016): note: consider using '%lls' in the format string
adapters\tlsio_schannel.c(1016): note: consider using '%Ls' in the format string
adapters\tlsio_schannel.c(1016): note: consider using '%ws' in the format string

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions