-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does the windows
crate still need no_std
support?
#1343
Comments
I just upgraded to 0.28.0 without enabling the std/alloc features, and I think I prefer not having any implicit allocations. 90% of the code is the same, with the exception of some HSTRING::from() calls. Including the HSTRING::from calls is good in my eyes, because it exposed a potential optimization in a few places in my code. I like having the implicit conversions and type-safety of the windows bindings over what is in windows-sys, but only if they are "zero-cost". |
Thanks for the feedback, I may keep the |
The pattern I've seen is that default-features = false This way, most users get the defaults and don't need to discover anything. I mention this because I considered using |
Since all APIs are off by default and need to be enabled with features, having defaults doesn't really help. Anyway, having |
Please reopen this issue, I failed to compile the crate under no_std. |
@kennykerr Some code can actually be written as imports to |
See #1343 (comment) |
@kennykerr but this would mean losing wrapper support for some types right? |
Do you have an example? I'm not sure what you mean. |
@kennykerr From the FAQ it said |
@kennykerr Is there anymore interest in having both windows and windows-sys support no_std? If not perhaps the FAQ should mention that you must use windows-sys to get no_std support. It doesn't look like there is a lot of code in windows that requires std. Have a way to disable std in windows would allow for a lot of benefits over windows-sys. I had to run
|
I don't see a compelling need for |
I just wanted to move from (regarded as deprecated) winapi crate, but sadly there's no support for DirectX 9 and 11 apis in windows-sys crate. I did some research and there few more developers that are facing similar issue: Is there any compelling reason against supporting |
The main difference is not https://kennykerr.ca/rust-getting-started/windows-or-windows-sys.html |
I'm well aware of that. Because of this comment I suggested to bring back |
Can you explain a bit more what you're trying to do? Why do you need |
I'm indeed targeting windows. For legal reasons I can't disclose much, but I'm part of the team that works on a plugin system. Plugins need to be build as DLLs with a custom entry point (that's why no_std is needed, but that's not the only reason). We explored other options but sadly We are currently using winapi, the whole idea of moving to windows crate came while I tried to port my old project (and so the issue). |
One approach to customizing the entry-point could be to do something as such: // build.rs
fn main()
{
println!("cargo:rustc-link-arg=/DEFAULTLIB:vcruntime.lib");
println!("cargo:rustc-link-arg=/DEFAULTLIB:ucrt.lib");
println!("cargo:rustc-link-arg=/ENTRY:ABC");
}
// main.rs
#![no_main]
#![windows_subsystem = "console"]
#[no_mangle]
pub extern "stdcall" fn ABC() {
println!("hello!");
} But sounds like you have other constraints waiting for me in the shadows 😅 |
We need fine-grained control over the library being produced (something related to sections and general file structure). I am not qualified enough to give enough details, but I have heard that this is the most important reason why we need My personal impression is that If this is indeed the case, then the current winapi bindings were sufficient for our project and we will probably stay with that. |
Now that the windows-sys crate is available, is there still a need for the
no_std
support in thewindows
crate? I'm just worried about the usability since its not very discoverable that you need to declare thestd
/alloc
features to use common features provided by thewindows
crate.The text was updated successfully, but these errors were encountered: