mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v.gen.c: fix compilation of if c_struct_1 != c_struct_2 {
This commit is contained in:
parent
cc4af235f3
commit
c86935309e
@ -7,7 +7,11 @@ import v.ast
|
|||||||
|
|
||||||
fn (mut g Gen) equality_fn(typ ast.Type) string {
|
fn (mut g Gen) equality_fn(typ ast.Type) string {
|
||||||
g.needed_equality_fns << typ.set_nr_muls(0)
|
g.needed_equality_fns << typ.set_nr_muls(0)
|
||||||
return g.typ(g.unwrap_generic(typ).set_nr_muls(0))
|
t1 := g.unwrap_generic(typ)
|
||||||
|
t2 := t1.set_nr_muls(0)
|
||||||
|
st2 := g.typ(t2)
|
||||||
|
res := st2.replace('struct ', '')
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut g Gen) gen_equality_fns() {
|
fn (mut g Gen) gen_equality_fns() {
|
||||||
|
4
vlib/v/gen/c/testdata/compare_structs.c.must_have
vendored
Normal file
4
vlib/v/gen/c/testdata/compare_structs.c.must_have
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
struct Something aaa = (struct Something){.fint = 0,.ff32 = 0,.fchar = 0,};
|
||||||
|
struct Something bbb = (struct Something){.fint = 0,.ff32 = 0,.fchar = 0,};
|
||||||
|
if (Something_struct_eq(aaa, bbb)) {
|
||||||
|
|
14
vlib/v/gen/c/testdata/compare_structs.vv
vendored
Normal file
14
vlib/v/gen/c/testdata/compare_structs.vv
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
struct C.Something {
|
||||||
|
fint int
|
||||||
|
ff32 f32
|
||||||
|
fchar char
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
aaa := C.Something{}
|
||||||
|
bbb := C.Something{}
|
||||||
|
if aaa == bbb {
|
||||||
|
println('ok')
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user