From 89cae4c4fefd46438f100f21a49fe51a34124721 Mon Sep 17 00:00:00 2001 From: a Date: Thu, 22 Jun 2017 14:44:21 +0200 Subject: [PATCH] Update README --- README.md | 11 +++-------- doc/pinkybar.1 | 13 +++++-------- doc/pinkybar.texi | 11 +++-------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index ebc78de..024f82f 100644 --- a/README.md +++ b/README.md @@ -824,9 +824,7 @@ By default I decided not to include Rust lang, but this doesn't mean you cannot ```rust #![crate_type = "staticlib"] -extern crate libc; - -use libc::c_char; +use std::os::raw::c_char; use std::ffi::CString; #[no_mangle] @@ -846,7 +844,7 @@ pub extern fn Rfree(s: *mut c_char) { } ``` -Compile to object code with `rustc --emit=obj lib.rs` +Compile to object code with `rustc --crate-type=staticlib lib.rs` **test.c** @@ -858,15 +856,12 @@ extern void Rfree(char *); int main(void) { char *str = hello(); - printf("%s\n", str); - Rfree(str); - return 0; } ``` -Compile with `gcc lib.o test.c -o test` +Compile with `gcc liblib.a test.c -o test -lpthread -ldl` --- diff --git a/doc/pinkybar.1 b/doc/pinkybar.1 index fd311d3..33944e7 100644 --- a/doc/pinkybar.1 +++ b/doc/pinkybar.1 @@ -1662,9 +1662,7 @@ cannot do it by hand: \f[C] #![crate_type\ =\ "staticlib"] -extern\ crate\ libc; - -use\ libc::c_char; +use\ std::os::raw::c_char; use\ std::ffi::CString; #[no_mangle] @@ -1685,7 +1683,8 @@ pub\ extern\ fn\ Rfree(s:\ *mut\ c_char)\ { \f[] .fi .PP -Compile to object code with \f[C]rustc\ \-\-emit=obj\ lib.rs\f[] +Compile to object code with +\f[C]rustc\ \-\-crate\-type=staticlib\ lib.rs\f[] .PP \f[B]test.c\f[] .IP @@ -1698,16 +1697,14 @@ extern\ void\ Rfree(char\ *); int\ main(void)\ { \ \ char\ *str\ =\ hello(); - \ \ printf("%s\\n",\ str); - \ \ Rfree(str); -\ \ return\ 0; } \f[] .fi .PP -Compile with \f[C]gcc\ lib.o\ test.c\ \-o\ test\f[] +Compile with +\f[C]gcc\ liblib.a\ test.c\ \-o\ test\ \-lpthread\ \-ldl\f[] .PP * * * * * .SS Wish list diff --git a/doc/pinkybar.texi b/doc/pinkybar.texi index 1ffde80..83eb558 100644 --- a/doc/pinkybar.texi +++ b/doc/pinkybar.texi @@ -1472,9 +1472,7 @@ cannot do it by hand: @verbatim #![crate_type = "staticlib"] -extern crate libc; - -use libc::c_char; +use std::os::raw::c_char; use std::ffi::CString; #[no_mangle] @@ -1494,7 +1492,7 @@ pub extern fn Rfree(s: *mut c_char) { } @end verbatim -Compile to object code with @code{rustc --emit=obj lib.rs} +Compile to object code with @code{rustc --crate-type=staticlib lib.rs} @strong{test.c} @@ -1506,15 +1504,12 @@ extern void Rfree(char *); int main(void) { char *str = hello(); - printf("%s\n", str); - Rfree(str); - return 0; } @end verbatim -Compile with @code{gcc lib.o test.c -o test} +Compile with @code{gcc liblib.a test.c -o test -lpthread -ldl} @iftex @bigskip@hrule@bigskip -- 2.11.0