diff --git a/compiler/parser.v b/compiler/parser.v index 35c682cfa0..b41677720b 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -1582,6 +1582,10 @@ fn (p mut Parser) name_expr() string { cfn := p.table.find_fn(name) or { // Not Found? Return 'void*' //return 'cvoid' //'void*' + if false { + p.warn('\ndefine imported C function with ' + + '`fn C.$name([args]) [return_type]`\n') + } return 'void*' } return cfn.typ diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index 834cb3c8b0..ac06e15a4f 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -33,6 +33,7 @@ pub fn _make(len, cap, elm_size int) array { return new_array(len, cap, elm_size) } + // Private function, used by V (`nums := [1, 2, 3]`) fn new_array_from_c_array(len, cap, elm_size int, c_array voidptr) array { arr := array { diff --git a/vlib/builtin/builtin.v b/vlib/builtin/builtin.v index f1000ad8d0..9d0708d9d2 100644 --- a/vlib/builtin/builtin.v +++ b/vlib/builtin/builtin.v @@ -4,6 +4,12 @@ module builtin +fn C.memcpy(byteptr, byteptr, int) +fn C.memmove(byteptr, byteptr, int) +//fn C.malloc(int) byteptr +fn C.realloc(byteptr, int) byteptr + + pub fn exit(code int) { C.exit(code) } diff --git a/vlib/math/math.v b/vlib/math/math.v index e1337a1205..097e8f9303 100644 --- a/vlib/math/math.v +++ b/vlib/math/math.v @@ -4,8 +4,6 @@ module math -#include - // NOTE // When adding a new function, please make sure it's in the right place. // All functions are sorted alphabetically. @@ -51,6 +49,8 @@ pub fn abs(a f64) f64 { return a } +fn C.acos(a f64) f64 + // acos calculates inverse cosine (arccosine). pub fn acos(a f64) f64 { return C.acos(a)