From aeaa05054b4ab2ce39a05c08ef6aaaccd5c3dde3 Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Mon, 16 Sep 2013 22:43:12 -0400 Subject: [PATCH] WinRT: ugh, at least one file in an app's project seems to require C++/CX compilation. Assuming this is true, that file might as well be the one that contains WinMain. --- src/main/winrt/SDL_winrt_main_NonXAML.cpp | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/winrt/SDL_winrt_main_NonXAML.cpp b/src/main/winrt/SDL_winrt_main_NonXAML.cpp index a9956afb0..6e61a40c0 100644 --- a/src/main/winrt/SDL_winrt_main_NonXAML.cpp +++ b/src/main/winrt/SDL_winrt_main_NonXAML.cpp @@ -1,6 +1,33 @@ #include +/* At least one file in any SDL/WinRT app appears to require compilation + with C++/CX, otherwise a Windows Metadata file won't get created, and + an APPX0702 build error can appear shortly after linking. + + The following set of preprocessor code forces this file to be compiled + as C++/CX, which appears to cause Visual C++ 2012's build tools to + create this .winmd file, and will help allow builds of SDL/WinRT apps + to proceed without error. + + If other files in an app's project enable C++/CX compilation, then it might + be possible for SDL_winrt_main_NonXAML.cpp to be compiled without /ZW, + for Visual C++'s build tools to create a winmd file, and for the app to + build without APPX0702 errors. In this case, if + SDL_WINRT_METADATA_FILE_AVAILABLE is defined as a C/C++ macro, then + the #error (to force C++/CX compilation) will be disabled. + + Please note that /ZW can be specified on a file-by-file basis. To do this, + right click on the file in Visual C++, click Properties, then change the + setting through the dialog that comes up. +*/ +#ifndef SDL_WINRT_METADATA_FILE_AVAILABLE +#ifndef __cplusplus_winrt +#error SDL_winrt_main_NonXAML.cpp must be compiled with /ZW, otherwise build errors due to missing .winmd files can occur. +#endif +#endif + + /* The app's C-style main will be passed into SDL.dll as a function pointer, and called at the appropriate time. */