compiler: first step to require explicit definition of imported C fns
parent
13e4c79f58
commit
cb31eeec55
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
module math
|
||||
|
||||
#include <math.h>
|
||||
|
||||
// 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)
|
||||
|
|
Loading…
Reference in New Issue