-
-
Save lachlansneff/af4b86830504ecd44233a729bae14956 to your computer and use it in GitHub Desktop.
Wasmer Wasm Sample App
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
// Define a function that is imported into the module. | |
// By default, the "env" namespace is used. | |
extern "C" { | |
fn print_str(ptr: *const u8, len: usize); | |
} | |
// Define a string that is accessible within the wasm | |
// linear memory. | |
static HELLO: &'static str = "Hello, World!"; | |
// Export a function named "hello_wasm". This can be called | |
// from the embedder! | |
#[no_mangle] | |
pub extern fn hello_wasm() { | |
// Call the function we just imported and pass in | |
// the offset of our string and its length as parameters. | |
unsafe { | |
print_str(HELLO.as_ptr(), HELLO.len()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment