Skip to content

Conversation

@emilio
Copy link
Contributor

@emilio emilio commented Nov 6, 2016

@@ -0,0 +1,5 @@
// bindgen-flags: --ctypes-prefix "libc" --use-core --raw-line "#![no_std]" --raw-line "mod libc { pub type c_int = i32; pub enum c_void {} }"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

poor man's libc :)

@emilio
Copy link
Contributor Author

emilio commented Nov 6, 2016

@bors-servo delegate=fitzgen

@bors-servo
Copy link

✌️ @fitzgen can now approve this pull request

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

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

LGTM, but one comment below.

@@ -0,0 +1,6 @@
// bindgen-flags: --use-core --raw-line "extern crate core;"
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't --use-core imply extern crate core; in the bindings? Shouldn't we automatically insert the extern crate definition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, at least not completely automatically I guess.

It's not uncommon doing include!("path/to/bindings.rs"), in which case it's unnecessary. In general it's completely unnecessary as long as the bindings aren't the crate root, so I went the easy/safe way. if it's harmless we can do it in a followup, in which case is straight-forward to do.

@alexisvl
Copy link

alexisvl commented Nov 7, 2016

Wow, that was fast. Thank you!

@emilio
Copy link
Contributor Author

emilio commented Nov 7, 2016

@bors-servo r=fitzgen

@bors-servo
Copy link

📌 Commit 6611276 has been approved by fitzgen

@bors-servo
Copy link

⌛ Testing commit 6611276 with merge 8c737ec...

bors-servo pushed a commit that referenced this pull request Nov 8, 2016
@bors-servo
Copy link

☀️ Test successful - status-travis

@bors-servo bors-servo merged commit 6611276 into rust-lang:master Nov 8, 2016
This was referenced Nov 8, 2016
@jdub
Copy link
Contributor

jdub commented Nov 8, 2016

Doesn't seem to output core in every instance, e.g. this is the output of the func_ptr.h test:

/* automatically generated by rust-bindgen */

extern "C" {
    #[link_name = "foo"]
    pub static mut foo:
               ::std::option::Option<unsafe extern "C" fn(x:
                                                              ::std::os::raw::c_int,
                                                          y:
                                                              ::std::os::raw::c_int)
                                         -> ::std::os::raw::c_int>;
}

@emilio
Copy link
Contributor Author

emilio commented Nov 8, 2016

@jdub good catch, that's a one-off :)

#229

@emilio emilio deleted the use-core branch November 8, 2016 13:33
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.

6 participants