This allows many of the crates in this repo to be compiled and used in #![no_std] environments. This is a requirement for some low-level components, especially within the implementation of Windows itself.
These crates are updated: windows, windows-core, windows-registry, windows-result. All of these crates now define a new feature, std, which is enabled by default. If you disable the std feature, then the crate will be compiled with #![no_std]. Because the std features are enabled by default, existing users of these crates should not see any difference in behavior.
Nearly all of the changes are extremely simple and do not change actual codegen. These just convert std::ptr::null_mut with core::ptr::null_mut, etc.
For those cases where a crate used dynamic memory containers (Box, String, Vec), I added an explicit dependency on the alloc crate and imported the needed types. These are the same types that are re-exported from std, so this also has no effect on codegen.
In a few cases, code was using things from std that are currently only available in std, such as OsString or Mutex. In those cases, I placed the code using those items under #[cfg(feature = "std")]. Since the std feature is enabled by default, this will not break any existing users of those crates.
I also noticed a bug in passing in BasicString. It can construct a &[u16] over a null pointer, which is UB. I've fixed that bug in this PR.
This allows many of the crates in this repo to be compiled and used in
#![no_std]
environments. This is a requirement for some low-level components, especially within the implementation of Windows itself.These crates are updated:
windows
,windows-core
,windows-registry
,windows-result
. All of these crates now define a new feature,std
, which is enabled by default. If you disable thestd
feature, then the crate will be compiled with#![no_std]
. Because thestd
features are enabled by default, existing users of these crates should not see any difference in behavior.Nearly all of the changes are extremely simple and do not change actual codegen. These just convert
std::ptr::null_mut
withcore::ptr::null_mut
, etc.For those cases where a crate used dynamic memory containers (Box, String, Vec), I added an explicit dependency on the
alloc
crate and imported the needed types. These are the same types that are re-exported fromstd
, so this also has no effect on codegen.In a few cases, code was using things from
std
that are currently only available instd
, such asOsString
orMutex
. In those cases, I placed the code using those items under#[cfg(feature = "std")]
. Since thestd
feature is enabled by default, this will not break any existing users of those crates.I also noticed a bug in passing in
BasicString
. It can construct a&[u16]
over a null pointer, which is UB. I've fixed that bug in this PR.