Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use FormatMessageA #230

Merged
merged 1 commit into from
Oct 21, 2022
Merged

Use FormatMessageA #230

merged 1 commit into from
Oct 21, 2022

Conversation

Thomas1664
Copy link
Contributor

@Thomas1664 Thomas1664 commented Oct 17, 2022

FormatMessage expects like FormatMessageW a wide char array. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessage and https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessagew for more information.

Using FormatMessage with a normal char array leads to a build failure on UWP:

D:\buildtrees\clickhouse-cpp\src\v2.2.1-26f006ec81.clean\clickhouse\base\socket.cpp(30): error C2664: 'DWORD FormatMessageW(DWORD,LPCVOID,DWORD,DWORD,LPWSTR,DWORD,va_list *)': cannot convert argument 5 from 'char [255]' to 'LPWSTR'
D:\buildtrees\clickhouse-cpp\src\v2.2.1-26f006ec81.clean\clickhouse\base\socket.cpp(30): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\um\winbase.h(2476): note: see declaration of 'FormatMessageW'

FormatMessageA expects an ordinary char array which translates to the desired output of this function, std::string. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessagea for more information.

I didn't change the input array to a wide array because changing the return type of the function might break users of it.

@CLAassistant
Copy link

CLAassistant commented Oct 17, 2022

CLA assistant check
All committers have signed the CLA.

@Enmk Enmk merged commit 52bdf94 into ClickHouse:master Oct 21, 2022
@Thomas1664 Thomas1664 deleted the fix-uwp-build branch October 24, 2022 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants