Skip to content

Instantly share code, notes, and snippets.

@crabtw
Created October 1, 2013 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crabtw/6773942 to your computer and use it in GitHub Desktop.
Save crabtw/6773942 to your computer and use it in GitHub Desktop.
#include <stdio.h>
void print_hello(void) {
printf("hello\n");
}
void print_hello(void);
CC = gcc
RUSTC = rustc
BINDGEN = bindgen
test: test.rs hello.rs libhello.so
$(RUSTC) $< -L . -o $@
hello.rs: hello.h
$(BINDGEN) -l hello $< -o $@
libhello.so: hello.c
$(CC) -fPIC -shared $< -o $@
clean:
$(RM) -f test hello.rs libhello.so
.PHONY: clean
mod hello;
#[fixed_stack_segment]
fn main() {
unsafe {
hello::print_hello();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment