From 8b98b8c8369deb6a677824afdc7b8f856454e76f Mon Sep 17 00:00:00 2001 From: Yuhang Zhao <2546789017@qq.com> Date: Thu, 1 Sep 2022 16:03:42 +0800 Subject: [PATCH] Win32: Add a W version entry point MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently we have a narrow version entry point, add a wide version entry point as well, make them share exactly the same implementation. The linker can choose the appropriate entry point during linking. The linker will always try to use wWinMain as the entry point function if the UNICODE/_UNICODE macros are passed to it and this will cause compilation failures without a wWinMain implementation. This patch fixes such issue, though it usually won't happen in most cases. Change-Id: I7bc22d5bdc1cf35514a335a280a9f18732531b25 Reviewed-by: Oliver Wolff Reviewed-by: MÃ¥rten Nordheim --- src/entrypoint/qtentrypoint_win.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/entrypoint/qtentrypoint_win.cpp b/src/entrypoint/qtentrypoint_win.cpp index 6ecb814948..f0cf46ba3d 100644 --- a/src/entrypoint/qtentrypoint_win.cpp +++ b/src/entrypoint/qtentrypoint_win.cpp @@ -36,7 +36,7 @@ static inline char *wideToMulti(unsigned int codePage, const wchar_t *aw) return result; } -extern "C" int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR /*cmdParamarg*/, int /* cmdShow */) +static inline int qtEntryPoint() { int argc = 0; wchar_t **argvW = CommandLineToArgvW(GetCommandLineW(), &argc); @@ -53,3 +53,13 @@ extern "C" int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR /*cmdParamarg*/, int delete [] argv; return exitCode; } + +extern "C" int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) +{ + return qtEntryPoint(); +} + +extern "C" int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int) +{ + return qtEntryPoint(); +}