-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unions and structs are not translated correctly if typedef is not used #190
Comments
Looks like it just skipped the union def altogether. |
Another example is with the input code: union MyUnion {
int a;
int b;
};
int main() {
union MyUnion u;
u.a = 10;
u.b = 100;
return 0;
} The below code is generated: @[translated]
module main
union MyUnion {
a int
b int
}
fn main() {
u := Union
MyUnion{}
u.a = 10
u.b = 100
return
} Which incorrectly sets The case which does work correctly is with: typedef union {
int a;
int b;
}MyUnion;
int main() {
MyUnion u;
u.a = 10;
u.b = 100;
return 0;
} Which correctly translates to: @[translated]
module main
union MyUnion {
a int
b int
}
fn main() {
u := MyUnion{}
u.a = 10
u.b = 100
return
} |
So the missing |
Seems to also affect structs. Here is some C code that has a struct inside and outside main: struct Outside {
int a;
int b;
};
int main() {
struct Outside o;
o.a = 1;
o.b = 2;
struct Inside {
int a;
int b;
};
struct Inside i;
i.a = 3;
i.b = 4;
} The struct outside main is handled correctly, but the struct definition inside main is removed: @[translated]
module main
struct Outside {
a int
b int
}
fn main() {
o := Outside{}
o.a = 1
o.b = 2
i := Inside{}
i.a = 3
i.b = 4
} |
Title updated to include both. |
Here is some C code that uses unions:
I run
v translate test.c
and it outputs the belowtest.v
:The above code will not compile successfully, as
u
is not defined:The text was updated successfully, but these errors were encountered: