summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 15a2640..5f86a61 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,16 +9,22 @@ use core::fmt::Write;
#[no_mangle]
pub extern "C" fn main(_nargs: libc::c_int, _args: *const *const libc::c_char) -> libc::c_int {
+ let mut stdout = unsafe { c::stdio::stdout() };
let x = c::string::CString::from("foo");
- let y = c::string::CBox::new(x);
+ let l = x.len();
+ let y = x.into_raw();
+ let z = unsafe {
+ c::string::CBox::slice_from_raw_parts(y, l)
+ };
+ //let y = unsafe { c::string::CBox::from_raw(x) };
//let foo = cstr!("Foo! %p\n");
//c::stdio::stdout().puts(foo);
- let mut stdout = c::stdio::stdout();
- writeln!(stdout, "Foo: {}", 42);
+ let _ = writeln!(stdout, "Foo: {} {} {}", z[0], z[1], z[2]);
0
}
#[panic_handler]
-fn panic(_info: &core::panic::PanicInfo) -> ! {
+fn panic(info: &core::panic::PanicInfo) -> ! {
+ let _ = writeln!(unsafe { c::stdio::stderr() }, "Panic: {}", info);
unsafe { libc::abort() }
}