How to compile
C/C++
const int* hash; // ascii representation
int main() { }
char* hash_addr() { return &hash[0]; }
int hash_len() { return hash.length(); }RUST
use std::ffi::CString;
use std::os::raw::c_char;
static HELLO: &'static str = "Yes, it Qan";
#[no_mangle]
pub fn get_hello() -> *mut c_char {
let s = CString::new(HELLO).unwrap();
s.into_raw()
}
#[no_mangle]
pub fn get_hello_len(i: i32) -> i32 {
HELLO.len() as i32
}Typescript
Last updated
Was this helpful?