mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
cgen: fix code for C ident when ptr is expected (#22259)
This commit is contained in:
parent
9a0f4d8461
commit
c866e375e2
3 changed files with 16 additions and 0 deletions
|
@ -2719,6 +2719,8 @@ fn (mut g Gen) ref_or_deref_arg(arg ast.CallArg, expected_type ast.Type, lang as
|
|||
if expected_type.has_flag(.option) {
|
||||
g.expr_with_opt(arg.expr, arg_typ, expected_type)
|
||||
return
|
||||
} else if arg.expr is ast.Ident && arg.expr.language == .c {
|
||||
g.write('(voidptr)')
|
||||
} else {
|
||||
g.write('(voidptr)&/*qq*/')
|
||||
}
|
||||
|
|
1
vlib/v/gen/c/testdata/c_ident_for_ptr_arg.c.must_have
vendored
Normal file
1
vlib/v/gen/c/testdata/c_ident_for_ptr_arg.c.must_have
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
int (*real_open) (charptr , int , int ) = ((main__RealOpen)((dl__sym((voidptr)RTLD_NEXT, _SLIT("open")))));
|
13
vlib/v/gen/c/testdata/c_ident_for_ptr_arg.vv
vendored
Normal file
13
vlib/v/gen/c/testdata/c_ident_for_ptr_arg.vv
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
module main
|
||||
|
||||
import dl
|
||||
|
||||
#flag -D_GNU_SOURCE
|
||||
|
||||
type RealOpen = fn(charptr, int, int) int
|
||||
|
||||
@[export: open]
|
||||
fn open(filename charptr, oflag int, mode int) int {
|
||||
real_open := RealOpen((dl.sym(C.RTLD_NEXT, "open")))
|
||||
return real_open(filename, oflag, mode)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue