File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -5,4 +5,14 @@ fn main() {
5
5
. cpp ( true )
6
6
. file ( "src/foo.cpp" )
7
7
. compile ( "foo" ) ;
8
+
9
+ cc:: Build :: new ( )
10
+ . define ( "APP_NAME" , "\" bar\" " )
11
+ . define (
12
+ "VERSION" ,
13
+ format ! ( "\" {}\" " , env!( "CARGO_PKG_VERSION" ) ) . as_str ( ) ,
14
+ )
15
+ . define ( "WELCOME" , None )
16
+ . file ( "src/bar.c" )
17
+ . compile ( "bar" ) ;
8
18
}
Original file line number Diff line number Diff line change
1
+ #include <stdio.h>
2
+
3
+ void print_app_info () {
4
+ #ifdef WELCOME
5
+ printf ("Welcome to " );
6
+ #endif
7
+ printf ("%s - version %s\n" , APP_NAME , VERSION );
8
+ }
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ extern "C" {
21
21
fn hello ( ) ;
22
22
fn greet ( name : * const c_char ) ;
23
23
fn multiply ( x : i32 , y : i32 ) -> i32 ;
24
+ fn print_app_info ( ) ;
24
25
}
25
26
26
27
fn main ( ) -> Result < ( ) > {
@@ -31,5 +32,8 @@ fn main() -> Result<()> {
31
32
unsafe {
32
33
println ! ( "{}" , multiply( 5 , 7 ) ) ;
33
34
}
35
+ unsafe {
36
+ print_app_info ( ) ;
37
+ }
34
38
Ok ( ( ) )
35
39
}
You can’t perform that action at this time.
0 commit comments