C++ - Introducing C++/WinRT RRS feed

  • General discussion

  • C++/WinRT is a standard C++ language projection for the Windows Runtime (WinRT) implemented solely in header files. It lets you both author and consume WinRT APIs using any standards-compliant C++ compiler, and is designed to provide C++ developers with first-class access to the modern Windows API.

    Read this article in the January 2017 issue of MSDN Magazine

    Sunday, January 1, 2017 10:21 PM

All replies

  • Kenny

    I read your article and tried to build the first example in in but the cl gives me this:

    c:\projects\winrttest\cppwinrt\10.0.14393.0\winrt\internal\../base.h(122): fatal error C1083: Cannot open include file: 'WindowsNumerics.impl.h': No such file or directory

    I cloned the repo in a subdirectory of my working folder where I put the Feed.cpp file.

    What am I missing?

    Monday, January 2, 2017 6:35 PM
  • If this include fails it means that you're targeting an older platform version. Please use 10.0.14393.0 or later.
    Tuesday, January 3, 2017 7:05 PM
  • C:\C++\WinRT>cl Feed.cpp /I cppwinrt\10.0.14393.0 /EHsc /std:c++latest

    Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24213.1 for x86

    Copyright (C) Microsoft Corporation.  All rights reserved.



    Microsoft (R) Incremental Linker Version 14.00.24213.1

    Copyright (C) Microsoft Corporation.  All rights reserved.




    LINK : fatal error LNK1104: cannot open file 'windowsapp.lib'

    Any ideas what is going wrong here? Thanks.
    Wednesday, January 4, 2017 4:26 PM
  • windowsapp is the lib file that tells the linker where to find the C-style WinRT functions used by a language projection. Make sure you have installed the 14393 (RS1) SDK as part of Visual Studio 2017 and have the various paths configured in your environment. Look for the “Developer Command Prompt for VS 2017 RC” in the Start menu. This should have it all set up for you.

    Wednesday, January 4, 2017 5:54 PM
  • I'm not sure I understand the significance of C++/WinRT.  Is this so you can write native Windows 10 apps in C++ without using UWP?  Is there a benefit to that?  I also don't understand the opposition to the C++/CX extensions.  I found those very intuitive and easy to adopt.
    Thursday, January 5, 2017 4:06 PM
  • John, did you build from a "Visual C++ tools command prompt"?  that should set up the include path for sdk headers, such as this one.
    Thursday, January 5, 2017 5:12 PM
  • C++/WinRT serves the same purpose as C++/CX: Writing applications that target the Windows Runtime.

    The significance of C++/WinRT is, that it delivers performance on par with WRL (or better). Arguably even more important: C++/WinRT (unlike C++/CX) doesn't lock you in to a single compiler and/or vendor. It's a Standard C++ library that any (modern) compiler can digest. This can be a strategic option that matters to some. It certainly matters to Microsoft's compiler division, as they no longer have to maintain two development tools for native development. Any feature of the C++ compiler is now instantly available to Desktop applications as well as UWP/Windows Store Apps.

    Saturday, January 21, 2017 5:41 PM
  • Kenny

    You wrote: C++/WinRT is not only for calling or using WinRT APIs, but it’s also ideally suited to implementing WinRT components

    I could not see how can I create a UWP-compatible component in C++/WinRT which expose some class and consume it in UWP application written in C#. In other words, is there available any sample how to create class in C++/WinRT inside a component, then instantiate and call its methods in UWP C#-project. Thank you!

    Alexander (aae)

    Tuesday, January 24, 2017 10:46 AM
  • Great article, Kenny.  One thing I noticed is that there doesn't appear to be a function named 'initialize'.  I searched the header and found 'init_apartment'.  Changing initialize to this made it compile / work.
    Friday, April 14, 2017 10:34 PM