From 97f04d8083ff6d456967ef21622755254dbdbc57 Mon Sep 17 00:00:00 2001 From: terminx Date: Wed, 11 Feb 2015 05:21:50 +0000 Subject: [PATCH] Fix program entry point on win32, allows debugging SDL builds under MSVC. git-svn-id: https://svn.eduke32.com/eduke32@4983 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/winbits.h | 1 + polymer/eduke32/build/src/sdlayer.c | 25 ++++++++++ polymer/eduke32/build/src/winbits.c | 63 +++++++++++++++++++++++++ 3 files changed, 89 insertions(+) diff --git a/polymer/eduke32/build/include/winbits.h b/polymer/eduke32/build/include/winbits.h index ac68073bd..be2afc6c5 100644 --- a/polymer/eduke32/build/include/winbits.h +++ b/polymer/eduke32/build/include/winbits.h @@ -30,3 +30,4 @@ extern LPTSTR GetWindowsErrorMsg(DWORD code); extern int32_t addsearchpath_ProgramFiles(const char *p); extern int32_t G_GetVersionFromWebsite(char *buffer); +extern int32_t win_buildargs(char **argvbuf); \ No newline at end of file diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 978c01916..86d0e2cec 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -327,7 +327,11 @@ static void sighandler(int signum) } } +#ifdef _WIN32 +int32_t WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int32_t nCmdShow) +#else int32_t main(int32_t argc, char *argv[]) +#endif { int32_t r; @@ -346,6 +350,11 @@ int32_t main(int32_t argc, char *argv[]) signal(SIGFPE, sighandler); #ifdef _WIN32 + UNREFERENCED_PARAMETER(hInst); + UNREFERENCED_PARAMETER(hPrevInst); + UNREFERENCED_PARAMETER(lpCmdLine); + UNREFERENCED_PARAMETER(nCmdShow); + win_open(); if (!CheckWinVersion()) @@ -366,7 +375,23 @@ int32_t main(int32_t argc, char *argv[]) maybe_redirect_outputs(); baselayer_init(); +#ifdef _WIN32 + char *argvbuf; + int32_t buildargc = win_buildargs(&argvbuf); + const char **buildargv = (const char **) Bmalloc(sizeof(char *)*(buildargc+1)); + char *wp = argvbuf; + + for (int i=0; i