Skip to content

Commit b2a30a1

Browse files
committed
Add comment explaining cast of u16 to pointer.
Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
1 parent 0eba417 commit b2a30a1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/platform/windows/wgl/context.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,14 @@ fn extension_loader_thread() -> WGLExtensionFunctions {
657657
assert_ne!(window_class_atom, 0);
658658

659659
let mut extension_functions = WGLExtensionFunctions::default();
660+
// The `lpClassName` parameter of `CreateWindowExA()` takes either
661+
// a pointer to a null-terminated c string, or an `ATOM` / `u16` encoded
662+
// in the lower bytes of the pointer type. We do the latter by forcing an
663+
// `as` cast of the ATOM to the pointer type `LPCSTR`.
664+
let lpClassName = window_class_atom as LPCSTR;
660665
let window = winuser::CreateWindowExA(
661666
0,
662-
window_class_atom as LPCSTR,
667+
lpClassName,
663668
window_class_name,
664669
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
665670
0,

0 commit comments

Comments
 (0)