Clang and the Windows Runtime

A compiler developer recently challenged me to see whether Modern produces code that Clang can compile. The Modern compiler produces a C++ library that is effectively a standard C++ language projection for the Windows Runtime. Given that it is standard C++, surely the Clang compiler will be able to handle it. As you can imagine, a compile-time language projection is going to rely quite heavily on generic programming so it took about an hour this morning to tweak the base library to support the particular way that Clang interprets the C++ standard. It was mostly a bunch of warnings about missing typename keywords in template type parameters. A short while later I built the first app targeting the Windows Runtime with Modern C++ and the Clang compiler.

clang

4 thoughts on “Clang and the Windows Runtime

  1. sbohmann

    Hi, I find it super-great to find a plausible answer to the question of how to develop against winrt at last πŸ™‚

    I’ve spent so many hours generating code for Java, C++, C# JS &c. from IDL input myself (not only COM idls but also corba and several more domain-specific variants).

    I realize that the real work you put in was probably not the generating-classes-from-an-idl part, since that’s nice and straight-forward once you’ve done it once, but rather dealing with all the peculiarities of COM, of which, unfortunately, there are many…

    Plus, getting to really understand WinRT, which sure must add even more peculiarities on top of those of COM πŸ™‚

    I would not endeavor rolling my own equivalent of what you did there, as long as I’m not really forced to, simply because of all the details you’ve already covered…

    Maybe you might want to put more emphasis on all the details and learning on top of the simple code generating part to get more appreciation from people with strong generative backgrounds who, unlike me, may otherwise underestimate the effort involved in rolling their own? πŸ™‚

    Because I really don’t want to see a situation where “roll your own generator” becomes the default tip for writing WinRT apps with standard C++ -.- πŸ™‚

    Thanks for your gigantic achievment, btw!! πŸ™‚

    Reply
    1. Kenny Kerr Post author

      Thanks, it certainly is a monumental effort. As you surmise, most of the challenge has been to produce the base library that deals with the translation of WinRT constructs and metadata as generic C++ for a compile-time projection.

      Reply
      1. sbohmann

        It’s always the monumental extra work that is grossly underestimated whenever someone has the great idea of “hey, I could write a generator for that” πŸ™‚

        Except, of course, for easy generation targets – e.g., whenever I have generated simple immutable value objects based on the standard data types and the standard library of a target language, be it the JDK, the STL, &c., for various projects, there never was anything monumental about it – and thankfulky so πŸ˜€

  2. sbohmann

    I’m just realizing that this project probably made you the person with the most knowledge about the low-level aspects of winrt outside ms πŸ™‚

    Luckily, I’m not currently involved in any Windows-related development, which makes it easy to refrain from asking you any questions in that area πŸ™‚

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s