mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix regression with unalised naming conflict with C interop (#18752)
This commit is contained in:
parent
c1550b3efa
commit
3f5995ace8
@ -22,7 +22,12 @@ fn (mut g Gen) struct_init(node ast.StructInit) {
|
|||||||
g.empty_line = false
|
g.empty_line = false
|
||||||
g.write(s)
|
g.write(s)
|
||||||
}
|
}
|
||||||
styp := g.typ(g.table.unaliased_type(node.typ)).replace('*', '')
|
unalised_typ := g.table.unaliased_type(node.typ)
|
||||||
|
styp := if g.table.sym(unalised_typ).language == .v {
|
||||||
|
g.typ(unalised_typ).replace('*', '')
|
||||||
|
} else {
|
||||||
|
g.typ(node.typ)
|
||||||
|
}
|
||||||
mut shared_styp := '' // only needed for shared x := St{...
|
mut shared_styp := '' // only needed for shared x := St{...
|
||||||
if styp in c.skip_struct_init {
|
if styp in c.skip_struct_init {
|
||||||
// needed for c++ compilers
|
// needed for c++ compilers
|
||||||
|
10
vlib/v/tests/modules/sub/foo.v
Normal file
10
vlib/v/tests/modules/sub/foo.v
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
module sub
|
||||||
|
|
||||||
|
import sub.foo.c
|
||||||
|
|
||||||
|
[typedef]
|
||||||
|
struct C.sub_foo {
|
||||||
|
a int
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type Foo = C.sub_foo
|
5
vlib/v/tests/modules/sub/foo/c/foo.h
Normal file
5
vlib/v/tests/modules/sub/foo/c/foo.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
typedef struct sub_foo sub_foo;
|
||||||
|
|
||||||
|
struct sub_foo {
|
||||||
|
int a;
|
||||||
|
};
|
7
vlib/v/tests/modules/sub/foo/c/foo.v
Normal file
7
vlib/v/tests/modules/sub/foo/c/foo.v
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module c
|
||||||
|
|
||||||
|
pub const used_import = 1
|
||||||
|
|
||||||
|
#flag -I @VMODROOT
|
||||||
|
|
||||||
|
#include "foo.h"
|
0
vlib/v/tests/modules/sub/foo/c/v.mod
Normal file
0
vlib/v/tests/modules/sub/foo/c/v.mod
Normal file
7
vlib/v/tests/modules/sub/sub_test.v
Normal file
7
vlib/v/tests/modules/sub/sub_test.v
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import sub
|
||||||
|
|
||||||
|
fn test_vmain() {
|
||||||
|
sub_foo := &sub.Foo{}
|
||||||
|
|
||||||
|
dump(sub_foo)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user