Skip to content
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

Add support for no_std #29

Merged
merged 1 commit into from Jan 12, 2016
Merged

Add support for no_std #29

merged 1 commit into from Jan 12, 2016

Conversation

Amanieu
Copy link
Contributor

@Amanieu Amanieu commented Jan 5, 2016

This PR adds support for no_std by adding a "no_std" cargo feature. The use of the cargo feature is needed for now because stable rust does not support no_std yet. Once 1.6.0 is released then the feature can be removed and bitflags can be made unconditionally no_std.

Fixes #27


#[cfg(all(feature = "no_std", test))]
#[macro_use]
extern crate std;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may actually be able to get away with extern crate std as core here and avoid the #[cfg] below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this?

// Compile the crate with no_std if possible. The "no_std" feature can be
// removed once no_std becomes available in 1.6.0 stable. In the meantime no_std
// must be disabled by default to allow the crate to work on older rust versions.
#![cfg_attr(feature = "no_std", no_std)]

#[cfg(all(feature = "no_std", test))]
#[macro_use]
extern crate std;

#[cfg(not(feature = "no_std"))]
extern crate std as core;

// Re-export libcore using an alias so that the macros can work in no_std crates
// while remaining compatible with normal crates.
#[doc(hidden)]
pub use core as __core;

@alexcrichton
Copy link
Contributor

Looks good to me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants