ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

win32-main.cpp

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 // Disable symbol overrides so that we can use system headers.
00024 #define FORBIDDEN_SYMBOL_ALLOW_ALL
00025 
00026 #include "common/scummsys.h"
00027 
00028 #ifdef WIN32
00029 
00030 // Fix for bug #2895217 "MSVC compilation broken with r47595":
00031 // We need to keep this on top of the "common/scummsys.h"(base/main.h) include,
00032 // otherwise we will get errors about the windows headers redefining
00033 // "ARRAYSIZE" for example.
00034 #define WIN32_LEAN_AND_MEAN
00035 #include <windows.h>
00036 
00037 #include "backends/platform/sdl/win32/win32.h"
00038 #include "backends/plugins/sdl/sdl-provider.h"
00039 #include "base/main.h"
00040 
00041 int __stdcall WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/,  LPSTR /*lpCmdLine*/, int /*iShowCmd*/) {
00042 #if !SDL_VERSION_ATLEAST(2, 0, 0)
00043     SDL_SetModuleHandle(GetModuleHandle(NULL));
00044 #endif
00045 // HACK: __argc, __argv are broken and return zero when using mingwrt 4.0+ on MinGW
00046 // HACK: MinGW-w64 based toolchains neither feature _argc nor _argv. The 32 bit
00047 // incarnation only defines __MINGW32__. This leads to build breakage due to
00048 // missing declarations. Luckily MinGW-w64 based toolchains define
00049 // __MINGW64_VERSION_foo macros inside _mingw.h, which is included from all
00050 // system headers. Thus we abuse that to detect them.
00051 #if defined(__GNUC__) && defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
00052     return main(_argc, _argv);
00053 #else
00054     return main(__argc, __argv);
00055 #endif
00056 }
00057 
00058 int main(int argc, char *argv[]) {
00059     // Create our OSystem instance
00060     g_system = new OSystem_Win32();
00061     assert(g_system);
00062 
00063     // Pre initialize the backend
00064     ((OSystem_Win32 *)g_system)->init();
00065 
00066 #ifdef DYNAMIC_MODULES
00067     PluginManager::instance().addPluginProvider(new SDLPluginProvider());
00068 #endif
00069 
00070     // Invoke the actual ScummVM main entry point:
00071     int res = scummvm_main(argc, argv);
00072 
00073     // Free OSystem
00074     g_system->destroy();
00075 
00076     return res;
00077 }
00078 
00079 #endif


Generated on Sat May 18 2019 05:01:29 for ResidualVM by doxygen 1.7.1
curved edge   curved edge