]>
git.proxmox.com Git - rustc.git/blob - compiler/rustc_codegen_cranelift/example/alloc_example.rs
1 #![feature(start, box_syntax, alloc_system, core_intrinsics, alloc_prelude, alloc_error_handler)]
5 extern crate alloc_system
;
7 use alloc
::prelude
::v1
::*;
9 use alloc_system
::System
;
12 static ALLOC
: System
= System
;
14 #[cfg_attr(unix, link(name = "c"))]
15 #[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
17 fn puts(s
: *const u8) -> i32;
21 fn panic_handler(_
: &core
::panic
::PanicInfo
) -> ! {
22 core
::intrinsics
::abort();
25 #[alloc_error_handler]
26 fn alloc_error_handler(_
: alloc
::alloc
::Layout
) -> ! {
27 core
::intrinsics
::abort();
31 fn main(_argc
: isize, _argv
: *const *const u8) -> isize {
32 let world
: Box
<&str> = box "Hello World!\0";
34 puts(*world
as *const str as *const u8);