-
Notifications
You must be signed in to change notification settings - Fork 13.3k
book should mention crates.io in FFI chapter #29762
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
Comments
Ugh... so the examples have a hidden |
The issue is, normally, you want to copy the code exactly, and put libc in your cargo.toml. That's why I hid it. |
Yeah, that makes sense. So maybe just a mention at the beginning about putting libc in Cargo.toml. And maaaybe another sentence about how if you click the examples some extra lines get inserted to make it compile in the playpen? (About half of them don't compile anyway since they refer to nonexistent libraries, though this could be fixed with even more hidden lines containing |
👍 |
Fun bash ...thing to pull code blocks out of a Markdown file and try compiling them: for block in $(grep -n '```' src/doc/trpl/ffi.md | paste -s -d ':\n' - | grep 'rust\|no_run')
do
from=$(echo $block | cut -d: -f1);
to=$(echo $block | cut -d: -f3);
f=$(mktemp /tmp/doctest.XXX);
head -$((to - 1)) src/doc/trpl/ffi.md | tail -$(($to - $from - 1)) | sed 's/^# //' >$f;
mr ru nightly rustc $f >/dev/null 2>&1 && rm doctest;
echo $from $?;
rm $f;
done |
|
Oh, how about that :) |
Does that not try linking? 'Cause it says everything passes but my bash script disagrees. |
…bnik Crates.io is now mentioned right at the top to try and head off the `#![feature(libc)]` error. In addition, the examples now all compile and run in the playpen. I also tweaked spacing in some of them. Fixes rust-lang#29762. r? @steveklabnik
If you blindly copy the example code from the FFI chapter you get the "libc is unstable" warning.
The text was updated successfully, but these errors were encountered: