mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 21:00:50 +00:00
Bug 472063 - mingw build failure: undefined reference to 'WinMain@16' in windbgdlg.cpp, r=neil, sr=bsmedberg
This commit is contained in:
parent
c2491862a8
commit
6482280bbb
@ -43,6 +43,65 @@
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
||||
/* MingW currently does not implement a wide version of the
|
||||
startup routines. Workaround is to implement something like
|
||||
it ourselves. See bug 472063 */
|
||||
|
||||
#include <shellapi.h>
|
||||
|
||||
int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
|
||||
|
||||
#undef __argc
|
||||
#undef __wargv
|
||||
|
||||
static int __argc;
|
||||
static wchar_t** __wargv;
|
||||
|
||||
int WINAPI
|
||||
WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPSTR lpszCommandLine, int nCmdShow)
|
||||
{
|
||||
LPWSTR commandLine = GetCommandLineW();
|
||||
|
||||
/* parse for __argc and __wargv for compatibility, since mingw
|
||||
* doesn't claim to support it :(
|
||||
*/
|
||||
__wargv = CommandLineToArgvW(commandLine, &__argc);
|
||||
if (!__wargv)
|
||||
return 127;
|
||||
|
||||
/* need to strip off any leading whitespace plus the first argument
|
||||
* (the executable itself) to match what should be passed to wWinMain
|
||||
*/
|
||||
while ((*commandLine <= L' ') && *commandLine) {
|
||||
++commandLine;
|
||||
}
|
||||
if (*commandLine == L'"') {
|
||||
++commandLine;
|
||||
while ((*commandLine != L'"') && *commandLine) {
|
||||
++commandLine;
|
||||
}
|
||||
if (*commandLine) {
|
||||
++commandLine;
|
||||
}
|
||||
} else {
|
||||
while (*commandLine > L' ') {
|
||||
++commandLine;
|
||||
}
|
||||
}
|
||||
while ((*commandLine <= L' ') && *commandLine) {
|
||||
++commandLine;
|
||||
}
|
||||
|
||||
int result = wWinMain(hInstance, hPrevInstance, commandLine, nCmdShow);
|
||||
LocalFree(__wargv);
|
||||
return result;
|
||||
}
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
|
||||
int WINAPI
|
||||
wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
||||
LPWSTR lpszCmdLine, int nCmdShow)
|
||||
|
Loading…
x
Reference in New Issue
Block a user