https://github.com/alvinhochun/mingw-w64-cppwinrt
Using the C++/WinRT language projection with
https://github.com/alvinhochun/mingw-w64-cppwinrt
cpp cpp20 cppwinrt mingw-w64 windows winrt
Last synced: about 1 month ago
JSON representation
Using the C++/WinRT language projection with
- Host: GitHub
- URL: https://github.com/alvinhochun/mingw-w64-cppwinrt
- Owner: alvinhochun
- License: mit
- Created: 2022-12-13T12:38:15.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-02-14T11:29:20.000Z (over 2 years ago)
- Last Synced: 2025-03-29T08:43:44.750Z (about 2 months ago)
- Topics: cpp, cpp20, cppwinrt, mingw-w64, windows, winrt
- Language: C++
- Homepage:
- Size: 2.02 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
C++/WinRT on MinGW-w64
======================[C++/WinRT][cppwinrt] is a C++ binding (officially "language projection") for the WinRT[^1] APIs. Originally developed by Kenny Kerr, it has become a part of the official Windows SDK and the recommended way to consume WinRT APIs from C++. See also the [official introduction to C++/WinRT][intro] and the [WinRT API reference][apiref].
C++/WinRT was made with MSVC in mind, but a series of changes to make it compatible with GCC and Clang (also libstdc++ and libc++ respectively) has been merged upstream, making it usable with various MinGW-w64 toolchains (with some limitations). This is a collection of documentation and example code intended to help you understand how to use this binding with a MinGW-w64 toolchain.
If you want to see how C++/WinRT works within Visual Studio, I attempted to document it [in a separate file](docs/how-its-done-in-visual-studio.md).
> **Note:** If you are using MSVC and Visual Studio, please use the [official NuGet package][nuget] instead.
> ⚠️ **Warning: The information here is work in progress and experimental.**
[^1]: Windows Runtime, not to be confused with the operating system that was called "Windows RT".
[cppwinrt]: https://github.com/microsoft/cppwinrt
[intro]: https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/
[apiref]: https://learn.microsoft.com/en-us/uwp/api/
[nuget]: https://www.nuget.org/packages/Microsoft.Windows.CppWinRT/Status
------* ✅ Calling simple WinRT APIs should work.
* ✅ Some test cases of the upstream test suite pass with MinGW-w64.
* ❌ XAML UI has not been explored but likely doesn't work out of the box.
* ❌ Authoring WinRT components is currently impossible (missing tooling to produce WinMD from IDL.)
* ⚠️ Consuming custom WinRT components may work but has not been tested.
* ⚠️ Anything involving coroutine needs more testing.
* ⚠️ Some untested functionality may break in various ways.Usage Guide
-----------### Toolchain
C++/WinRT requires C++20 for its coroutine support. (C++/WinRT officially supports C++17 but only with MSVC-specific coroutine extensions.) You will need a rather recent compiler. You should also try to get the latest MinGW-w64 runtime and headers.
Compilers:
* LLVM/Clang:
* ✅ LLVM 15 is recommended.
* 🔲 LLVM 14 is untested.
* ⚠️ LLVM 13 does not work out of the box due to missing a floating point `std::to_chars` implementation in libc++, but can be worked around by disabling the `winrt::to_hstring(float)` and `winrt::to_hstring(double)` overloads (https://github.com/microsoft/cppwinrt/pull/1257). It also contains only experimental coroutine support (the stabilized implementation is only available since libc++ 14) so anything involving coroutines should be considered unstable and to be avoided.
* ⚠️ Earlier versions are untested.
* GCC:
* ✅ GCC 12 in MSYS2 has been tested to work.
* 🔲 GCC 11 is untested.
* ⚠️ GCC 10 is missing a floating point `std::to_chars` implementation in libc++ (same as LLVM 13).
* ❌ GCC 9 and earlier do not support coroutine.Tested toolchains:
* [llvm-mingw](https://github.com/mstorsjo/llvm-mingw)
* [MSYS2](https://www.msys2.org/)### Using cppwinrt with Prebuilt Headers
Headers are built on [GitHub Actions][GHA] workflow runs and made available as build artifacts.
[GHA]: https://github.com/alvinhochun/mingw-w64-cppwinrt/actions
### Build System Integration
This project provides both CMake config file and pkg-config file in the releases for using the headers with build systems such as CMake and Autotools. To see how these integrations work, you can check the [examples](examples/). Better documentation may be added in the future.
(I am still figuring this out, so details are subject to change.)
### Building Upstream cppwinrt Directly
If you want to use the upstream cppwinrt tool directly and without build system integration, please refer to [Using Upstream cppwinrt](docs/using-upstream-cppwinrt.md).
Licence
-------All code and resources in this repository are released under the MIT License,
unless otherwise specified.