Created
February 13, 2018 21:30
-
-
Save aisamanra/2e1285fd662af649cfc32087b77f38d5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#include <stdio.h> | |
extern int add(int, int); | |
int | |
main(int argc, char* argv[]) | |
{ | |
printf("2 + 3 = %d\n", add(2, 3)); | |
return 0; | |
} |
This file contains hidden or 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
main: libsample.a | |
gcc -lpthread -ldl main.c libsample.a -o main | |
libsample.a: sample.rs | |
rustc --crate-type=staticlib sample.rs | |
clean: | |
rm -f main libsample.a |
This file contains hidden or 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
#[no_mangle] | |
pub extern "C" fn add(x: isize, y: isize) -> isize { | |
x + y | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment