diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2020-04-04 01:47:30 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2020-04-04 01:47:30 +0200 |
commit | 52b498494534784c77bfa4a93706be40620ebd9a (patch) | |
tree | d8499f6bec9a452231c4fcfc4d05d6b450cebf1b /src/main.rs | |
parent | 9aae18d76454b01f07b177efafcc9867dfa7dff1 (diff) | |
download | neco-52b498494534784c77bfa4a93706be40620ebd9a.tar neco-52b498494534784c77bfa4a93706be40620ebd9a.zip |
Lots of changes
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 14 |
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() } } |