locked
Writing WinRT component in C

    Question

  • Hi!

    I have some legacy code which is written in c using WIN32API extensively . This component is called from C++ code.

    I want to port this code to WInRT  to make it work on arm based processors.

    Here are my questions on this :

    (1) Does memory allocation mechanisam in c like malloc , calloc and caling conventions remain same ?

    (2) I could not find much support to write WinRT code in c , all  i found are samples in managed c++ code.

    Where can i find pure c implementions using winRT ?

    Your help is highly appreciated.

    Thanks And Regards,

    Sravan Vurapalli

    Monday, November 19, 2012 10:00 AM

Answers

  • Hi Sravan Vurapalli,

    If you want to target the application to ARM processor.
    Then you have to consider things in following thread.
    http://stackoverflow.com/questions/13016861/what-in-c-can-make-windows-8-apps-not-run-on-arm

    You have to target the WinRT(Windows API for building windows8 store apps).

    If you are target ARM architecture.
    Please go through the following blog and it clear all your clarifications.
    http://blogs.msdn.com/b/b8/archive/2012/02/09/building-windows-for-the-arm-processor-architecture.aspx

    From Blog:
    Developers wishing to target WOA do so by writing applications for the WinRT (Windows APIs for building Metro style apps)
    using the new Visual Studio 11 tools in a variety of languages, including C#/VB/XAML and Jscript/ HTML5.
    Native code targeting WinRT is also supported using C and C++,
    which can be targeted across architectures and distributed through the Windows Store.

    Go through this thread as well - http://social.msdn.microsoft.com/Forums/en-US/tailoringappsfordevices/thread/e45359b5-8f8e-4e93-ad28-ce7a29a3876d

    As it is different processor architecture you have to use the runtime WinRT.


    thanks,
    Bhash

     

     



    Tuesday, November 20, 2012 4:44 PM
  • The CRT / Standard Library works basically the same for Win32 desktop apps and Windows Store apps. There are a few functions in the C++11 Standard Library that are not available for Windows Store apps, so it's a subset that is truly 'portable', but things like malloc, etc. work fine for x86, x64, and ARM. I cover this in my article Dual-use Coding Techniques for Games.

    There are distinct ABIs in effect for x86, x64, and ARM although mostly this is hidden from you as a C/C++ programmer. This really only comes into play if you are trying to optimize or when writing assembly. The Windows Store app ABI for x86 and x64 is the same as the Win32 desktop ABI for x86 and x64 that has been used for years.

    Using WinRT APIs from C is possible, but extremely painful. Ideally your C library only uses a small subset of Win32 APIs that are supported for Windows Store apps, can use the Standard Library, or you write a few extern "C" helper functions written in C++/CX that provide the required functionality.


    Wednesday, November 28, 2012 8:54 PM

All replies

  • Hi Sravan Vurapalli,

    If you want to target the application to ARM processor.
    Then you have to consider things in following thread.
    http://stackoverflow.com/questions/13016861/what-in-c-can-make-windows-8-apps-not-run-on-arm

    You have to target the WinRT(Windows API for building windows8 store apps).

    If you are target ARM architecture.
    Please go through the following blog and it clear all your clarifications.
    http://blogs.msdn.com/b/b8/archive/2012/02/09/building-windows-for-the-arm-processor-architecture.aspx

    From Blog:
    Developers wishing to target WOA do so by writing applications for the WinRT (Windows APIs for building Metro style apps)
    using the new Visual Studio 11 tools in a variety of languages, including C#/VB/XAML and Jscript/ HTML5.
    Native code targeting WinRT is also supported using C and C++,
    which can be targeted across architectures and distributed through the Windows Store.

    Go through this thread as well - http://social.msdn.microsoft.com/Forums/en-US/tailoringappsfordevices/thread/e45359b5-8f8e-4e93-ad28-ce7a29a3876d

    As it is different processor architecture you have to use the runtime WinRT.


    thanks,
    Bhash

     

     



    Tuesday, November 20, 2012 4:44 PM
  • Thanks bash!

    Will go through them and came back if have any questions .

    Thanks And Regards,

    Sravan Vurapalli

    Monday, November 26, 2012 6:59 AM
  • The CRT / Standard Library works basically the same for Win32 desktop apps and Windows Store apps. There are a few functions in the C++11 Standard Library that are not available for Windows Store apps, so it's a subset that is truly 'portable', but things like malloc, etc. work fine for x86, x64, and ARM. I cover this in my article Dual-use Coding Techniques for Games.

    There are distinct ABIs in effect for x86, x64, and ARM although mostly this is hidden from you as a C/C++ programmer. This really only comes into play if you are trying to optimize or when writing assembly. The Windows Store app ABI for x86 and x64 is the same as the Win32 desktop ABI for x86 and x64 that has been used for years.

    Using WinRT APIs from C is possible, but extremely painful. Ideally your C library only uses a small subset of Win32 APIs that are supported for Windows Store apps, can use the Standard Library, or you write a few extern "C" helper functions written in C++/CX that provide the required functionality.


    Wednesday, November 28, 2012 8:54 PM