You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: uwp/cpp-and-winrt-apis/interop-winrt-abi.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
description: This topic shows how to convert between application binary interface (ABI) and C++/WinRT objects.
3
3
title: Interop between C++/WinRT and the ABI
4
-
ms.date: 11/30/2018
4
+
ms.date: 09/29/2023
5
5
ms.topic: article
6
6
keywords: windows 10, uwp, standard, c++, cpp, winrt, projection, port, migrate, interop, ABI
7
7
ms.localizationpriority: medium
@@ -13,6 +13,9 @@ This topic shows how to convert between SDK application binary interface (ABI) a
13
13
14
14
In general, C++/WinRT exposes ABI types as **void\***, so that you don't need to include platform header files.
15
15
16
+
> [!NOTE]
17
+
> In the code examples, we use `reinterpret_cast` (rather than `static_cast`) in an effort to *telegraph* what are inherently unsafe casts.
18
+
16
19
## What is the Windows Runtime ABI, and what are ABI types?
17
20
A Windows Runtime class (runtime class) is really an abstraction. This abstraction defines a binary interface (the Application Binary Interface, or ABI) that allows various programming languages to interact with an object. Regardless of programming language, client code interaction with a Windows Runtime object happens at the lowest level, with client language constructs translated into calls into the object's ABI.
18
21
@@ -149,11 +152,11 @@ For the lowest-level conversions, which only copy addresses, you can use the [**
149
152
// Lowest-level conversions that only copy addresses
150
153
151
154
// Convert to a non-owning ABI object with get_abi.
| Extract **HSTRING** from **hstring**|`h = static_cast<HSTRING>(get_abi(s));`|*s* still owns the string. |
356
+
| Extract **HSTRING** from **hstring**|`h = reinterpret_cast<HSTRING>(get_abi(s));`|*s* still owns the string. |
354
357
| Detach **HSTRING** from **hstring**|`h = reinterpret_cast<HSTRING>(detach_abi(s));`|*s* no longer owns the string. |
355
358
| Set **HSTRING** into **hstring**|`*put_abi(s) = h;`|*s* takes ownership of string. Any string previously owned by *s* is leaked (will assert in debug). |
356
359
| Receive **HSTRING** into **hstring**|`GetString(reinterpret_cast<HSTRING*>(put_abi(s)));`|*s* takes ownership of string. Any string previously owned by *s* is leaked (will assert in debug). |
0 commit comments