Open KivApple opened 1 year ago
You need to compile your own sdl2-sys bindings with the "use-bindgen" feature, by default they are Linux variant (not that we don't want to include all of the platforms, but SDL auto-detects the host platform so we can't have generic sdl2-sys bindings).
I've got an error:
Compiling sdl2-sys v0.35.2
error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
--> C:\Users\kiv\Projects\my_app\target\debug\build\sdl2-sys-2e0686f7ed6e4fb0\out/sdl_bindings.rs:74524:1
|
74524 | pub struct _IMAGE_TLS_DIRECTORY64 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: `_IMAGE_TLS_DIRECTORY64__bindgen_ty_1__bindgen_ty_1` has a `#[repr(align)]` attribute
--> C:\Users\kiv\Projects\my_app\target\debug\build\sdl2-sys-2e0686f7ed6e4fb0\out/sdl_bindings.rs:74542:1
|
74542 | pub struct _IMAGE_TLS_DIRECTORY64__bindgen_ty_1__bindgen_ty_1 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: `_IMAGE_TLS_DIRECTORY64` contains a field of type `_IMAGE_TLS_DIRECTORY64__bindgen_ty_1`
--> C:\Users\kiv\Projects\my_app\target\debug\build\sdl2-sys-2e0686f7ed6e4fb0\out/sdl_bindings.rs:74530:9
|
74530 | pub __bindgen_anon_1: _IMAGE_TLS_DIRECTORY64__bindgen_ty_1,
| ^^^^^^^^^^^^^^^^
note: ...which contains a field of type `_IMAGE_TLS_DIRECTORY64__bindgen_ty_1__bindgen_ty_1`
--> C:\Users\kiv\Projects\my_app\target\debug\build\sdl2-sys-2e0686f7ed6e4fb0\out/sdl_bindings.rs:74536:9
|
74536 | pub __bindgen_anon_1: _IMAGE_TLS_DIRECTORY64__bindgen_ty_1__bindgen_ty_1,
| ^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0588`.
The following warnings were emitted during compilation:
warning: couldn't execute `llvm-config --prefix` (error: program not found)
warning: set the LLVM_CONFIG_PATH environment variable to the full path to a valid `llvm-config` executable (including the executable itself)
error: could not compile `sdl2-sys` due to previous error
In the meantime, I think there are not a lot platform-specific structures (I actually see only two - SDL_SysWMmsg
and SDL_SysWMinfo
) and it might be possible to dispatch them in Rust using cfgs rather than in C.
I aplogise for the necro, just posting this in the case anyone else needs to retrieve the HWND: https://gist.github.com/bane9/4b5839bf3828e5b10136e9ac72c76481
Usually in C/C++ code you are able to retrive WinAPI window handle like this:
But it's impossible in Rust:
It seems that Rust sdl2-sys bindings missing platform-specific union values and on any platform offer only Linux union variants.