f65801e69f
A code analysis warning recently fired for a customer on detach_abi(com_array<T>). This function returns a std::pair<uint32_t, some_pointer_type>, which will have, on 64-bit builds, 4 bytes of padding between the uint32 size and the pointer members. Currently, that padding is uninitialized. The idea behind the code analysis warning is that information may be leaked via those unitialized bytes. In practice, that's almost never going to be an issue for this function, because the std::pair is not an interesting object to pass around, and only exists as a convenience to return both the size and buffer of the com_array at the same time. However, the fix removes a pain point for a customer, is simple, risk-free, and actually gets optimized away in the 99% use case (return value stored in a local variable, access only the first/second members, not the padding bytes). Demo showing optimization: https://godbolt.org/z/T4vPhMKxn |
||
---|---|---|
cppwinrt | ||
fast_fwd | ||
natvis | ||
nuget | ||
prebuild | ||
scratch | ||
strings | ||
test | ||
vsix | ||
.gitattributes | ||
.gitignore | ||
CODE_OF_CONDUCT.md | ||
Directory.Build.Props | ||
Directory.Build.Targets | ||
LICENSE | ||
README.md | ||
SECURITY.md | ||
build_nuget.cmd | ||
build_projection.cmd | ||
build_test_all.cmd | ||
build_vsix.cmd | ||
compile_tests.cmd | ||
cppwinrt.sln | ||
run_tests.cmd |
README.md
The C++/WinRT language projection
C++/WinRT is an entirely standard C++ language projection for Windows Runtime (WinRT) APIs, implemented as a header-file-based library, and designed to provide you with first-class access to the modern Windows API. With C++/WinRT, you can author and consume Windows Runtime APIs using any standards-compliant C++17 compiler.
- Documentation: https://aka.ms/cppwinrt
- NuGet package: http://aka.ms/cppwinrt/nuget
- Visual Studio extension: http://aka.ms/cppwinrt/vsix
- Wikipedia: https://en.wikipedia.org/wiki/C++/WinRT
Building C++/WinRT
Don't build C++/WinRT yourself - just download the latest version here: https://aka.ms/cppwinrt/nuget
If you really want to build it yourself, the simplest way to do so is to run the build_test_all.cmd
script in the root directory. Developers needing to work on the C++/WinRT compiler itself should go through the following steps to arrive at an efficient inner loop:
- Open a dev command prompt pointing at the root of the repo.
- Open the
cppwinrt.sln
solution. - Build the x64 Release configuration of the
prebuild
andcppwinrt
projects only. Do not attempt to build anything else just yet. - Run
build_projection.cmd
in the dev command prompt. - Switch to the x64 Debug configuration in Visual Studio and build all projects as needed.
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.