none
Command Line: Which API Family defines for Windows Phone 8 and Windows RT? RRS feed

  • Question

  • Hello,

    I'm porting a nmake-based C/C++ library to Windows 8, Windows Phone 8, and Windows RT. From a Visual Studio 2012 project, I can figure out INCLUDE, PATH, LIB, and LIBPATH by dumping the environment in a Custom Build step.

    However, I have not been able to determine which Windows API family defines should be used with a Windows Phone project and a Windows RT project. Visual Studio does not place the defines on the command line, so they are missing from the compiler output.

    Windows Phone (in a cross compile environment):

       C:\Program Files (x86)\Microsoft Visual Studio11.0\VC\include\crtdefs.h(338):
       fatal error C1189: #error : Compiling Desktop applications for the ARM platform
       is not supported.

    Windows RT (in a cross compile environment):

       C:\Program Files (x86)\Microsoft Visual Studio11.0\VC\include\crtdefs.h(338):
       fatal error C1189: #error : Compiling Desktop applications for the ARM platform
       is not supported.

    Images of screen captures are here (windows-phone-compile.png) and here (windows-rt-compile.png).

    I believe I am missing, for example, /D WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP for the Windows Phone project.

    What is Microsoft's official position? What should I be using for the defines? Platforms are Windows 8 (Store and Desktop (2 each)), Windows Phone 8 (Store (1 each)), and Windows RT (Store and Desktop (2 each)).

    Thanks in advance,

    Jeff

    PS, Sorry if this is the wrong group. The only other relevant discussion pointed folks here for Windows API family questions.


    Sunday, August 11, 2013 3:18 PM

Answers

  • Visual Studio is defining the appropriate extra defines via the MSBuild rules in the .props files for the various targets, which is why it's not explicitly listed in the IDE as compiler options.

    For VS 2012 targeting Windows phone 8, you'd use:

    /DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP

    For VS 2012 targeting Windows Store apps

    /DWINAPI_FAMILY=WINAPI_FAMILY_APP

    You are getting the error above because without an explicitly set WINAPI_FAMILY, it defaults to WINAPI_FAMILY_DESKTOP_APP.

    Note that these are subject to change with future versions of Visual Studio and Windows SDKs. In fact, there are some changes for the Windows 8.1 SDK in the VS 2013 Preview w.r.t. to Windows phone. Be sure to review winapifamily.h when you move to this newer toolset.


    Monday, August 12, 2013 5:10 AM