sdl

FORK: Simple Directmedia Layer
git clone https://git.neptards.moe/neptards/sdl.git
Log | Files | Refs

SDL_winrt_main_NonXAML.cpp (2088B)


      1 /*
      2     SDL_winrt_main_NonXAML.cpp, placed in the public domain by David Ludwig  3/13/14
      3 */
      4 
      5 #include "SDL_main.h"
      6 #include <wrl.h>
      7 
      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.
     11 
     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.
     16 
     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.
     23 
     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.
     27 */
     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.
     31 #endif
     32 #endif
     33 
     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
     37    function).
     38 
     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).
     41 */
     42 #ifdef _MSC_VER
     43 #pragma warning(disable:4447)
     44 #endif
     45 
     46 /* Make sure the function to initialize the Windows Runtime gets linked in. */
     47 #ifdef _MSC_VER
     48 #pragma comment(lib, "runtimeobject.lib")
     49 #endif
     50 
     51 int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
     52 {
     53     return SDL_WinRTRunApp(SDL_main, NULL);
     54 }