Last active
November 24, 2022 19:21
-
-
Save mcpherrinm/d5bdccc44feb40e4d11f to your computer and use it in GitHub Desktop.
Hello World in Rust without the runtime (libcore and libc only)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![no_std] | |
extern crate core; | |
use core::option::{None, Some}; | |
use core::iter::Iterator; | |
use core::str::StrSlice; | |
#[lang="stack_exhausted"] | |
pub extern "C" fn rust_stack_exhausted() { | |
unsafe { core::intrinsics::abort() } | |
} | |
#[lang="begin_unwind"] pub fn begin_unwind(){ } | |
#[lang="eh_personality"] pub fn eh_personality() {} | |
#[link(name="c")] | |
#[allow(ctypes)] | |
extern { fn putchar(_:int)->int; } | |
#[start] | |
fn start(_:int, _:**u8)->int { | |
for c in "Hello, World!\n".bytes() { | |
unsafe {putchar(c as int); } | |
} | |
0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment