Skip to content

Commit 1c73bd1

Browse files
test add C function
1 parent ff92249 commit 1c73bd1

File tree

7 files changed

+23
-8
lines changed

7 files changed

+23
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
如果想向其中添加其余函数:
2323

24-
- C\C++: [详见添加方法](./command/c_build/README.md)
24+
- C\C++: [详见添加方法](./command/src/c_build/README.md)
2525
- rust: [详间rust添加方法](./command/src/commands/README.md)
2626

2727
## 功能特点

command/bin/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,15 @@ fn main() {
2323
// init shell
2424
init_shell(&mut session_context)
2525
}
26+
27+
/* C test
28+
#[link(name="hello")]
29+
extern "C"{
30+
fn hello();
31+
}
32+
33+
fn main(){
34+
unsafe{
35+
hello()
36+
}
37+
}*/

command/build.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
fn main(){
2-
// file: c_build/your.c\
2+
// file: ./src/c_build/c/your.c
33
// compile: your function name
4+
// if your function is cpp, you can {.cpp(true)}
45
cc::Build::new()
5-
.file("");
6+
.file("./src/c_build/c/example.c")
7+
.compile("hello");
68
}

command/c_build/c/example.c

Lines changed: 0 additions & 5 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.

command/src/c_build/c/example.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include <stdio.h>
2+
3+
4+
void hello(){
5+
printf("welcome to 'C' \n");
6+
}

0 commit comments

Comments
 (0)