in ver.0.11.0: Windows::Win32::UI::Shell::NOTIFYICONDATAW is "#[repr(C, packed(1))]" so Shell_NotifyIconW fails
in ver.0.10.0: it is "#[repr(C)]", Shell_NotifyIconW goes OK
The issue can be reproduced using the following:
Cargo.toml:
[package]
name = "shell_test"
version = "0.0.0"
edition = "2018"
[dependencies]
windows = "0.11.0"
[build-dependencies]
windows = "0.11.0"
build.rs:
fn main() {
windows::build!(
Windows::Win32::UI::Shell::NOTIFYICONDATAW,
);
}
main.rs:
mod bindings {
windows::include_bindings!();
}
fn main() {}
cargo build --target i686-pc-windows-msvc produces the 32-bit bindingscargo build --target x86_64-pc-windows-msvc produces the 64-bit bindingsAccording to the Windows SDK headers, the NOTIFIYICONDATAW structure should be packed(1), unless the target architecture is _WIN64 (not sure whether that includes ARM64).
The metadata contains type definitions for both byte-packed and natural type layout, presumably gated on the SupportedArchitecture attribute (which ILSpy won't display, though it should), but those don't translate into the generated bindings.
unless the target architecture is _WIN64 (not sure whether that includes ARM64).
ARM64 sets _WIN64 - doc says:
_WIN64 Defined as 1 when the compilation target is 64-bit ARM or x64. Otherwise, undefined.
The metadata now includes arch-specific struct definitions, but the Windows crate doesn't yet sniff out the target for the build and generate the appropriate definitions.
Most helpful comment
The issue can be reproduced using the following:
Cargo.toml:
build.rs:
main.rs:
cargo build --target i686-pc-windows-msvcproduces the 32-bit bindingscargo build --target x86_64-pc-windows-msvcproduces the 64-bit bindingsAccording to the Windows SDK headers, the
NOTIFIYICONDATAWstructure should bepacked(1), unless the target architecture is_WIN64(not sure whether that includes ARM64).The metadata contains type definitions for both byte-packed and natural type layout, presumably gated on the
SupportedArchitectureattribute (which ILSpy won't display, though it should), but those don't translate into the generated bindings.