Hi Christophe, > i can not use : > let ppDb : **mut () = RawPtr::null(); > unsafe { res=sqlite3_open(filename.as_ptr(), ppDb); > because as_ptr() returns an *u8 and c_char is a i8, so i have to use > extern { fn sqlite3_open(filename: *c_uchar, ppDb : **mut ()) -> > c_int; }
as_ptr() is a bad idea as there is no guarantee that Rust string is null-terminated. It should be safer to use with_c_str like: filename.with_c_str(|c_str| unsafe { sqlite3_open(c_str, ppDb) }) More details here: http://static.rust-lang.org/doc/master/std/c_str/trait.ToCStr.html#method.with_c_str > Now, suppose i use > extern { fn sqlite3_errmsg(pDb : *mut ()) -> *c_uchar; } I believe it actually should be extern { fn sqlite3_errmsg(pDB: *mut()) -> *c_char; } And for creating an owned string from it you can use std::str::raw::from_c_str More details here: http://static.rust-lang.org/doc/master/std/str/raw/fn.from_c_str.html -- Valerii _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev