Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
Forked from anonymous/Makefile
Last active December 28, 2015 01:49
Show Gist options
  • Save alexcrichton/7423809 to your computer and use it in GitHub Desktop.
Save alexcrichton/7423809 to your computer and use it in GitHub Desktop.
void foo(void(*)());
void bar() {
}
int main() {
foo(bar);
return 0;
}
extern mod rustuv;
use std::rt;
use std::ptr;
#[no_mangle]
pub extern "C" fn foo(c_callback: extern "C" fn()) {
do rt::start(0, ptr::null()) {
c_callback();
};
}
all: libfoo.dylib bar.c
clang bar.c -o bar -L. -lfoo -Wl,-rpath,`pwd`
libfoo.dylib: foo.rs
rustc --lib foo.rs -Z gen-crate-map
ln -nsf libfoo-*.dylib libfoo.dylib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment