about summary refs log tree commit diff
path: root/example
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2019-02-11 19:18:52 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2019-02-11 19:18:52 +0100
commitc68e76c33bf8b8e3fc0dabb3f7d9133328a7ea6d (patch)
treeaf7a860c4eed847a6d4116a42a78c83c3e39bb75 /example
parent4bb8bfca94aa704b2f57f33d2f6be121ee88e3fa (diff)
downloadrust-c68e76c33bf8b8e3fc0dabb3f7d9133328a7ea6d.tar.gz
rust-c68e76c33bf8b8e3fc0dabb3f7d9133328a7ea6d.zip
Implement variadic function calling
Diffstat (limited to 'example')
-rw-r--r--example/mini_core.rs1
-rw-r--r--example/mini_core_hello_world.rs2
2 files changed, 3 insertions, 0 deletions
diff --git a/example/mini_core.rs b/example/mini_core.rs
index 0ddd3ade401..4da661ebb8d 100644
--- a/example/mini_core.rs
+++ b/example/mini_core.rs
@@ -338,6 +338,7 @@ pub mod libc {
     #[link(name = "c")]
     extern "C" {
         pub fn puts(s: *const u8);
+        pub fn printf(format: *const char, ...) -> i32;
         pub fn malloc(size: usize) -> *mut u8;
         pub fn free(ptr: *mut u8);
         pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);
diff --git a/example/mini_core_hello_world.rs b/example/mini_core_hello_world.rs
index 1254d917189..17c64ffe09f 100644
--- a/example/mini_core_hello_world.rs
+++ b/example/mini_core_hello_world.rs
@@ -121,6 +121,8 @@ fn main() {
     //return;
 
     unsafe {
+        printf("Hello %s\n\0" as *const str as *const char, "printf\0" as *const str as *const char);
+
         let hello: &[u8] = b"Hello\0" as &[u8; 6];
         let ptr: *const u8 = hello as *const [u8] as *const u8;
         puts(ptr);