mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
@VMODULE relative paths in #flag lines
This commit is contained in:
3
vlib/compiler/tests/project_with_c_code/.gitignore
vendored
Normal file
3
vlib/compiler/tests/project_with_c_code/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
main
|
||||
mod1/c/implementation.o
|
||||
main_test
|
8
vlib/compiler/tests/project_with_c_code/main.v
Normal file
8
vlib/compiler/tests/project_with_c_code/main.v
Normal file
@ -0,0 +1,8 @@
|
||||
module main
|
||||
|
||||
import mod1
|
||||
|
||||
fn main(){
|
||||
res := mod1.vadd(1,2)
|
||||
println( res )
|
||||
}
|
5
vlib/compiler/tests/project_with_c_code/main_test.v
Normal file
5
vlib/compiler/tests/project_with_c_code/main_test.v
Normal file
@ -0,0 +1,5 @@
|
||||
import mod1
|
||||
|
||||
fn test_using_c_code_in_the_same_module_works(){
|
||||
assert 1003 == mod1.vadd(1,2)
|
||||
}
|
6
vlib/compiler/tests/project_with_c_code/mod1/c/header.h
Normal file
6
vlib/compiler/tests/project_with_c_code/mod1/c/header.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef ADD_H
|
||||
#define ADD_H
|
||||
|
||||
int cadd(int a, int b);
|
||||
|
||||
#endif
|
@ -0,0 +1,5 @@
|
||||
#include "header.h"
|
||||
|
||||
int cadd(int a, int b) {
|
||||
return a + b;
|
||||
}
|
12
vlib/compiler/tests/project_with_c_code/mod1/wrapper.v
Normal file
12
vlib/compiler/tests/project_with_c_code/mod1/wrapper.v
Normal file
@ -0,0 +1,12 @@
|
||||
module mod1
|
||||
|
||||
#flag -I @VMODULE/c
|
||||
#flag @VMODULE/c/implementation.o
|
||||
|
||||
#include "header.h"
|
||||
|
||||
fn C.cadd(int,int) int
|
||||
|
||||
pub fn vadd(a int, b int) int {
|
||||
return 1000 + C.cadd(a,b)
|
||||
}
|
Reference in New Issue
Block a user