mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
c defs
This commit is contained in:
parent
98c016b41d
commit
dca49e43d9
@ -17,11 +17,6 @@ fn init() {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
13
vlib/builtin/cdefs.v
Normal file
13
vlib/builtin/cdefs.v
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2019 Alexander Medvednikov. All rights reserved.
|
||||
// Use of this source code is governed by an MIT license
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
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
|
||||
|
||||
//fn C.qsort()
|
||||
|
@ -49,7 +49,6 @@ fn (p mut Parser) enum_decl(_enum_name string) {
|
||||
if p.tok == .comma {
|
||||
p.next()
|
||||
}
|
||||
// TODO free name [memory]
|
||||
val++
|
||||
}
|
||||
p.table.register_type2(Type {
|
||||
|
@ -1264,6 +1264,7 @@ fn (p mut Parser) gen(s string) {
|
||||
|
||||
// Generate V header from V source
|
||||
fn (p mut Parser) statement(add_semi bool) string {
|
||||
//p.expected_type = ''
|
||||
if p.returns && !p.is_vweb {
|
||||
p.error('unreachable code')
|
||||
}
|
||||
@ -1982,6 +1983,8 @@ fn (p mut Parser) get_const_type(name string, is_ptr bool) string {
|
||||
}
|
||||
|
||||
fn (p mut Parser) get_c_func_type(name string) string {
|
||||
//p.warn(name + ' ' + p.expected_type)
|
||||
//}
|
||||
f := Fn {
|
||||
name: name
|
||||
is_c: true
|
||||
@ -1994,9 +1997,10 @@ fn (p mut Parser) get_c_func_type(name string) 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')
|
||||
//if false {
|
||||
if p.expected_type != '' && p.expected_type != 'void' {
|
||||
p.warn('\ndefine imported C function with ' +
|
||||
'`fn C.$name([args]) [return_type]`\n')
|
||||
}
|
||||
return 'void*'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user