-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Here is some C code that uses unions:
#include <stdio.h>
int main() {
union {
int i;
int j;
} u;
u.i = 3;
u.j = 5;
printf("%d, %d\n", u.i, u.j);
return 0;
}
I run v translate test.c
and it outputs the below test.v
:
@[translated]
module main
fn main() {
u.i = 3
u.j = 5
C.printf(c'%d, %d\n', u.i, u.j)
return
}
The above code will not compile successfully, as u
is not defined:
test.v:5:2: error: undefined ident: `u`
3 |
4 | fn main() {
5 | u.i = 3
| ^
6 | u.j = 5
7 | C.printf(c'%d, %d\n', u.i, u.j)
test.v:5:4: error: `u` does not return a value
3 |
4 | fn main() {
5 | u.i = 3
| ^
6 | u.j = 5
7 | C.printf(c'%d, %d\n', u.i, u.j)
test.v:5:4: error: unexpected symbol `void`
3 |
4 | fn main() {
5 | u.i = 3
| ^
6 | u.j = 5
7 | C.printf(c'%d, %d\n', u.i, u.j)
test.v:6:2: error: undefined ident: `u`
4 | fn main() {
5 | u.i = 3
6 | u.j = 5
| ^
7 | C.printf(c'%d, %d\n', u.i, u.j)
8 | return
test.v:6:4: error: `u` does not return a value
4 | fn main() {
5 | u.i = 3
6 | u.j = 5
| ^
7 | C.printf(c'%d, %d\n', u.i, u.j)
8 | return
test.v:6:4: error: unexpected symbol `void`
4 | fn main() {
5 | u.i = 3
6 | u.j = 5
| ^
7 | C.printf(c'%d, %d\n', u.i, u.j)
8 | return
test.v:7:24: error: undefined ident: `u`
5 | u.i = 3
6 | u.j = 5
7 | C.printf(c'%d, %d\n', u.i, u.j)
| ^
8 | return
9 | }
test.v:7:26: error: `u` does not return a value
5 | u.i = 3
6 | u.j = 5
7 | C.printf(c'%d, %d\n', u.i, u.j)
| ^
8 | return
9 | }
andrey-kun
Metadata
Metadata
Assignees
Labels
No labels