2 SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig 3/13/14
8 /* At least one file in any SDL/WinRT app appears to require compilation
9 with C++/CX, otherwise a Windows Metadata file won't get created, and
10 an APPX0702 build error can appear shortly after linking.
12 The following set of preprocessor code forces this file to be compiled
13 as C++/CX, which appears to cause Visual C++ 2012's build tools to
14 create this .winmd file, and will help allow builds of SDL/WinRT apps
15 to proceed without error.
17 If other files in an app's project enable C++/CX compilation, then it might
18 be possible for SDL_winrt_main_NonXAML.cpp to be compiled without /ZW,
19 for Visual C++'s build tools to create a winmd file, and for the app to
20 build without APPX0702 errors. In this case, if
21 SDL_WINRT_METADATA_FILE_AVAILABLE is defined as a C/C++ macro, then
22 the #error (to force C++/CX compilation) will be disabled.
24 Please note that /ZW can be specified on a file-by-file basis. To do this,
25 right click on the file in Visual C++, click Properties, then change the
26 setting through the dialog that comes up.
28 #ifndef SDL_WINRT_METADATA_FILE_AVAILABLE
29 #ifndef __cplusplus_winrt
30 #error SDL_winrt_main_NonXAML.cpp must be compiled with /ZW, otherwise build errors due to missing .winmd files can occur.
34 /* Prevent MSVC++ from warning about threading models when defining our
35 custom WinMain. The threading model will instead be set via a direct
36 call to Windows::Foundation::Initialize (rather than via an attributed
39 To note, this warning (C4447) does not seem to come up unless this file
40 is compiled with C++/CX enabled (via the /ZW compiler flag).
43 #pragma warning(disable:4447)
46 /* Make sure the function to initialize the Windows Runtime gets linked in. */
48 #pragma comment(lib, "runtimeobject.lib")
51 int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
53 return SDL_WinRTRunApp(SDL_main, NULL);